JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> ok to omit possible super-types, right? null, null, null, null, false); } /** * Method that should NOT to be used by application code: * it does NOT properly handle inspection of super-types, so neither parent * Classes nor implemented Interfaces are accessible with resulting type * instance. Instead, please use {@link TypeFactory}'s <code>constructType</code> * methods which handle introspection appropriately. *<p> * Note that prior to 2.7, method usage was not limited and would typically * have worked acceptably: the problem comes from inability to resolve super-type * information, for which {@link TypeFactory} is needed. * * @deprecated Since 2.7 */ @Deprecated public static SimpleType construct(Class<?> cls) { /* Let's add sanity checks, just to ensure no * Map/Collection entries are constructed */ if (Map.class.isAssignableFrom(cls)) { throw new IllegalArgumentException("Can not construct SimpleType for a Map (class: "+cls.getName()+")"); } if (Collection.class.isAssignableFrom(cls)) { throw new IllegalArgumentException("Can not construct SimpleType for a Collection (class: "+cls.getName()+")"); } // ... and while we are at it, not array types either @Override public JavaType withContentTypeHandler(Object h) { // no content type, so: throw new IllegalArgumentException("Simple types have no content types; can not call withContenTypeHandler()"); } @Override public SimpleType withValueHandler(Object h) { if (h == _valueHandler) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, h, _typeHandler, _asStatic); } @Override public SimpleType withContentValueHandler(Object h) { // no content type, so: throw new IllegalArgumentException("Simple types have no content types; can not call withContenValueHandler()"); } @Override public SimpleType withStaticTyping() { return _asStatic ? this : new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, _typeHandler, true); } @Override public JavaType refine(Class<?> rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) { // SimpleType means something not-specialized, so: return null; } @Override protected String buildCanonicalName() { StringBuilder sb = new StringBuilder(); sb.append(_class.getName()); final int count = _bindings.size(); if (count > 0) { sb.append('<'); for (int i = 0; i < count; ++i) { JavaType t = containedType(i

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> kind = Std.STD_TIME_ZONE; } else if (rawType == InetAddress.class) { kind = Std.STD_INET_ADDRESS; } else if (rawType == InetSocketAddress.class) { kind = Std.STD_INET_SOCKET_ADDRESS; } else { return null; } return new Std(rawType, kind); } /* /********************************************************** /* Deserializer implementations /********************************************************** */ @SuppressWarnings("unchecked") @Override public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { // Issue#381 if (p.getCurrentToken() == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final T value = deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single '" + _valueClass.getName() + "' value but there was more than a single value in the array"); } return value; } // 22-Sep-2012, tatu: For 2.1, use this new method, may force coercion: String text = p.getValueAsString(); if (text != null) { // has String representation if (text.length() == 0 || (text = text.trim()).length() == 0) { // 04-Feb-2013, tatu: Usually should become null; but not always return _deserializeFromEmptyString(); } Exception cause = null; try { T result = _deserialize(text, ctxt); if (result != null) { return result; } } catch (IllegalArgumentException iae) { cause = iae; } String msg = "not a valid textual representation"; if (cause != null) { String m2 = cause.getMessage(); if (m2 != null) { msg = msg + ", problem: "+m2; } } JsonMappingException e = ctxt.weirdStringException(text, _valueClass, msg); if (cause != null) { e.initCause(cause); } throw e; // nothing to do here, yet? We'll fail anyway } if (p.getCurrentToken() == JsonToken.VALUE_EMBEDDED_OBJECT) { // Trivial cases; null to null, instance of type itself returned as is Object ob = p.getEmbeddedObject(); if (ob == null) { return null; } if (_valueClass.isAssignableFrom(ob.getClass())) { return (T) ob; } return _deserializeEmbedded(

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> intoValue) throws IOException { if (_delegateType.getRawClass().isAssignableFrom(intoValue.getClass())){ return (T) _delegateDeserializer.deserialize(p, ctxt, intoValue); } return (T) _handleIncompatibleUpdateValue(p, ctxt, intoValue); } /** * Overridable handler method called when {@link #deserialize(JsonParser, DeserializationContext, Object)} * has been called with a value that is not compatible with delegate value. * Since no conversion are expected for such "updateValue" case, this is normally not * an operation that can be permitted, and the default behavior is to throw exception. * Sub-classes may choose to try alternative approach if they have more information on * exact usage and constraints. * * @since 2.6 */ protected Object _handleIncompatibleUpdateValue(JsonParser p, DeserializationContext ctxt, Object intoValue) throws IOException { throw new UnsupportedOperationException(String.format ("Can not update object of type %s (using deserializer for type %s)" +intoValue.getClass().getName(), _delegateType)); } /* /********************************************************** /* Overridable methods /********************************************************** */ /** * Method called to convert from "delegate value" (which was deserialized * from JSON using standard Jackson deserializer for delegate type) * into desired target type. *<P> * The default implementation uses configured {@link Converter} to do * conversion. * * @param delegateValue * * @return Result of conversion */ protected T convertValue(Object delegateValue) { return _converter.convert(delegateValue); } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.io.IOException; import java.util.Iterator; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.ContainerSerializer; import com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase; @SuppressWarnings("serial") @JacksonStdImpl public class IteratorSerializer extends AsArraySerializerBase<Iterator<?>> { public IteratorSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts) { super(Iterator.class, elemType, staticTyping, vts, null); } public IteratorSerializer(IteratorSerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSerializer, Boolean unwrapSingle) { super(src, property, vts, valueSerializer, unwrapSingle); } @Override public boolean isEmpty(SerializerProvider prov, Iterator<?> value) { return (value == null) || !value.hasNext(); } @Override public boolean hasSingleElement(Iterator<?> value) { // no really good way to determine (without consuming iterator), so: return false; } @Override public ContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts) { return new IteratorSerializer(this, _property, vts, _elementSerializer, _unwrapSingle); } @Override public IteratorSerializer withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle) { return new IteratorSerializer(this, property, vts, elementSerializer, unwrapSingle); } @Override public final void serialize(Iterator<?> value, JsonGenerator gen, SerializerProvider provider) throws IOException { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { if (hasSingleElement(value)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(); serializeContents(value, gen, provider); gen.writeEndArray(); } @Override public void serializeContents(Iterator<?> value, JsonGenerator gen, SerializerProvider provider) throws IOException { if (value.hasNext()) { final TypeSerializer typeSer = _valueTypeSerializer; JsonSerializer<Object> prevSerializer = null; Class<?> prevClass = null; do { Object elem = value.next(); if (elem == null) { provider.defaultSerializeNull(gen); continue; } JsonSerializer<Object> currSerializer = _element

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.exc; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import com.fasterxml.jackson.core.JsonLocation; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.JsonMappingException; /** * Base class for {@link JsonMappingException}s that are specifically related * to problems related to binding an individual property. * * @since 2.3 */ @SuppressWarnings("serial") public abstract class PropertyBindingException extends JsonMappingException { /** * Class that does not contain mapping for the unrecognized property. */ protected final Class<?> _referringClass; /** *<p> * Note: redundant information since it is also included in the * reference path. */ protected final String _propertyName; /** * Set of ids of properties that are known for the type, if this * can be statically determined. */ protected final Collection<Object> _propertyIds; /** * Lazily constructed description of known properties, used for * constructing actual message if and as needed. */ protected transient String _propertiesAsString; /** * @since 2.7 */ protected PropertyBindingException(JsonParser p, String msg, JsonLocation loc, Class<?> referringClass, String propName, Collection<Object> propertyIds) { super(p, msg, loc); _referringClass = referringClass; _propertyName = propName; _propertyIds = propertyIds; } /** * @deprecated Since 2.7 */ @Deprecated // since 2.7 protected PropertyBindingException(String msg, JsonLocation loc, Class<?> referringClass, String propName, Collection<Object> propertyIds) { this(null, msg, loc, referringClass, propName, propertyIds); } /* /********************************************************** /* Overrides /********************************************************** */ /** * Somewhat arbitrary limit, but let's try not to create uselessly * huge error messages */ private final static int MAX_DESC_LENGTH = 1000; @Override public String getMessageSuffix() { String suffix = _propertiesAsString; if (suffix == null && _propertyIds != null) { StringBuilder sb = new StringBuilder(100); int len = _propertyIds.size(); if (len == 1) { sb.append(" (one known property: \""); sb.append(String.valueOf(_propertyIds.iterator().next())); sb.append('"'); } else { sb.append(" (").append(len).append(" known properties: "); Iterator<Object> it = _propertyIds.iterator(); while (it.hasNext())

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> { sb.append('"'); sb.append(String.valueOf(it.next())); sb.append('"'); // one other thing: limit max length if (sb.length() > MAX_DESC_LENGTH) { sb.append(" [truncated]"); break; } if (it.hasNext()) { sb.append(", "); } } } sb.append("])"); _propertiesAsString = suffix = sb.toString(); } return suffix; } /* /********************************************************** /* Extended API /********************************************************** */ /** * Method for accessing type (class) that is missing definition to allow * binding of the unrecognized property. */ public Class<?> getReferringClass() { return _referringClass; } /** * Convenience method for accessing logical property name that could * not be mapped. Note that it is the last path reference in the * underlying path. */ public String getPropertyName() { return _propertyName; } public Collection<Object> getKnownPropertyIds() { if (_propertyIds == null) { return null; } return Collections.unmodifiableCollection(_propertyIds); } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>erringProperties()) { continue; } // as per [databind#675], allow resolution at this point if (tryToResolveUnresolvedObjectId(roid)) { continue; } if (exception == null) { exception = new UnresolvedForwardReference(getParser(), "Unresolved forward references for: "); } Object key = roid.getKey().key; for (Iterator<Referring> iterator = roid.referringProperties(); iterator.hasNext(); ) { Referring referring = iterator.next(); exception.addUnresolvedId(key, referring.getBeanType(), referring.getLocation()); } } if (exception != null) { throw exception; } } /** * Overridable helper method called to try to resolve otherwise unresolvable {@link ReadableObjectId}; * and if this succeeds, return <code>true</code> to indicate problem has been resolved in * some way, so that caller can avoid reporting it as an error. *<p> * Default implementation simply calls {@link ReadableObjectId#tryToResolveUnresolved} and * returns whatever it returns. * * @since 2.6 */ protected boolean tryToResolveUnresolvedObjectId(ReadableObjectId roid) { return roid.tryToResolveUnresolved(this); } /* /********************************************************** /* Abstract methods impls, other factory methods /********************************************************** */ @SuppressWarnings("unchecked") @Override public JsonDeserializer<Object> deserializerInstance(Annotated ann, Object deserDef) throws JsonMappingException { if (deserDef == null) { return null; } JsonDeserializer<?> deser; if (deserDef instanceof JsonDeserializer) { deser = (JsonDeserializer<?>) deserDef; } else { /* Alas, there's no way to force return type of "either class * X or Y" -- need to throw an exception after the fact */ if (!(deserDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned deserializer definition of type "+deserDef.getClass().getName()+"; expected type JsonDeserializer or Class<JsonDeserializer> instead"); } Class<?> deserClass = (Class<?>)deserDef; // there are some known "no class" markers to consider too: if (deserClass == JsonDeserializer.None.class || ClassUtil.isBogusClass(deserClass)) { return null; } if (!JsonDeserializer.class.isAssignableFrom(deserClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+deserClass.getName()+"; expected Class<JsonDeserializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); deser = (hi == null) ? null : hi.deserializerInstance(_config, ann, deserClass); if (de

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>ser == null) { deser = (JsonDeserializer<?>) ClassUtil.createInstance(deserClass, _config.canOverrideAccessModifiers()); } } // First: need to resolve if (deser instanceof ResolvableDeserializer) { ((ResolvableDeserializer) deser).resolve(this); } return (JsonDeserializer<Object>) deser; } @Override public final KeyDeserializer keyDeserializerInstance(Annotated ann, Object deserDef) throws JsonMappingException { if (deserDef == null) { return null; } KeyDeserializer deser; if (deserDef instanceof KeyDeserializer) { deser = (KeyDeserializer) deserDef; } else { if (!(deserDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned key deserializer definition of type " +deserDef.getClass().getName() +"; expected type KeyDeserializer or Class<KeyDeserializer> instead"); } Class<?> deserClass = (Class<?>)deserDef; // there are some known "no class" markers to consider too: if (deserClass == KeyDeserializer.None.class || ClassUtil.isBogusClass(deserClass)) { return null; } if (!KeyDeserializer.class.isAssignableFrom(deserClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+deserClass.getName() +"; expected Class<KeyDeserializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); deser = (hi == null) ? null : hi.keyDeserializerInstance(_config, ann, deserClass); if (deser == null) { deser = (KeyDeserializer) ClassUtil.createInstance(deserClass, _config.canOverrideAccessModifiers()); } } // First: need to resolve if (deser instanceof ResolvableDeserializer) { ((ResolvableDeserializer) deser).resolve(this); } return deser; } /* /********************************************************** /* Extended API /********************************************************** */ /** * Fluent factory method used for constructing a blueprint instance * with different factory */ public abstract DefaultDeserializationContext with(DeserializerFactory factory); /** * Method called to create actual usable per-deserialization * context instance. */ public abstract DefaultDeserializationContext createInstance( DeserializationConfig config, JsonParser jp, InjectableValues values); /* /********************************************************** /* And then the concrete implementation class /********************************************************** */ /** * Actual full concrete implementation */ public final static class Impl extends DefaultDeserializationContext { private static final long serialVersionUID = 1L; /** * Default constructor for a blueprint object, which will use the standard * {@link DeserializerCache}, given factory. */ public Impl(DeserializerFactory df) { super(df, null); } protected Impl

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> information is not needed, * only class info. */ protected BasicBeanDescription(MapperConfig<?> config, JavaType type, AnnotatedClass classDef, List<BeanPropertyDefinition> props) { super(type); _propCollector = null; _config = config; _annotationIntrospector = (_config == null) ? null : _config.getAnnotationIntrospector(); _classInfo = classDef; _properties = props; } protected BasicBeanDescription(POJOPropertiesCollector coll) { this(coll, coll.getType(), coll.getClassDef()); _objectIdInfo = coll.getObjectIdInfo(); } /** * Factory method to use for constructing an instance to use for building * deserializers. */ public static BasicBeanDescription forDeserialization(POJOPropertiesCollector coll) { return new BasicBeanDescription(coll); } /** * Factory method to use for constructing an instance to use for building * serializers. */ public static BasicBeanDescription forSerialization(POJOPropertiesCollector coll) { return new BasicBeanDescription(coll); } /** * Factory method to use for constructing an instance to use for purposes * other than building serializers or deserializers; will only have information * on class, not on properties. */ public static BasicBeanDescription forOtherUse(MapperConfig<?> config, JavaType type, AnnotatedClass ac) { return new BasicBeanDescription(config, type, ac, Collections.<BeanPropertyDefinition>emptyList()); } protected List<BeanPropertyDefinition> _properties() { if (_properties == null) { _properties = _propCollector.getProperties(); } return _properties; } /* /********************************************************** /* Limited modifications by core databind functionality /********************************************************** */ /** * Method that can be used to prune unwanted properties, during * construction of serializers and deserializers. * Use with utmost care, if at all... * * @since 2.1 */ public boolean removeProperty(String propName) { Iterator<BeanPropertyDefinition> it = _properties().iterator(); while (it.hasNext()) { BeanPropertyDefinition prop = it.next(); if (prop.getName().equals(propName)) { it.remove(); return true; } } return false; } public boolean addProperty(BeanPropertyDefinition def) { // first: ensure we do not have such property if (hasProperty(def.getFullName())) { return false; } _properties().add(def); return true; } /** * @since 2.6 */ public boolean hasProperty(PropertyName name) { return findProperty(name) != null; } /** * @since 2.6 */ public BeanPropertyDefinition

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> exists null is returned. * If more than one are found, an exception is thrown. */ @Override public AnnotatedMember findAnyGetter() throws IllegalArgumentException { AnnotatedMember anyGetter = (_propCollector == null) ? null : _propCollector.getAnyGetter(); if (anyGetter != null) { /* For now let's require a Map; in future can add support for other * types like perhaps Iterable<Map.Entry>? */ Class<?> type = anyGetter.getRawType(); if (!Map.class.isAssignableFrom(type)) { throw new IllegalArgumentException("Invalid 'any-getter' annotation on method "+anyGetter.getName()+"(): return type is not instance of java.util.Map"); } } return anyGetter; } @Override public Map<String,AnnotatedMember> findBackReferenceProperties() { HashMap<String,AnnotatedMember> result = null; // boolean hasIgnored = (_ignoredPropertyNames != null); for (BeanPropertyDefinition property : _properties()) { /* 23-Sep-2014, tatu: As per [Databind#426], we _should_ try to avoid * calling accessor, as it triggers exception from seeming conflict. * But the problem is that _ignoredPropertyNames here only contains * ones ignored on per-property annotations, but NOT class annotations... * so commented out part does not work, alas */ /* if (hasIgnored && _ignoredPropertyNames.contains(property.getName())) { continue; } */ AnnotatedMember am = property.getMutator(); if (am == null) { continue; } AnnotationIntrospector.ReferenceProperty refDef = _annotationIntrospector.findReferenceType(am); if (refDef != null && refDef.isBackReference()) { if (result == null) { result = new HashMap<String,AnnotatedMember>(); } String refName = refDef.getName(); if (result.put(refName, am) != null) { throw new IllegalArgumentException("Multiple back-reference properties with name '"+refName+"'"); } } } return result; } /* /********************************************************** /* Introspection for deserialization, factories /********************************************************** */ @Override public List<AnnotatedMethod> getFactoryMethods() { // must filter out anything that clearly is not a factory method List<AnnotatedMethod> candidates = _classInfo.getStaticMethods(); if (candidates.isEmpty()) { return candidates; } ArrayList<AnnotatedMethod> result = new ArrayList<AnnotatedMethod>(); for (AnnotatedMethod am : candidates) { if (isFactoryMethod(am)) { result.add(am); } } return result; } @Override public Constructor<?>

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> findSingleArgConstructor(Class<?>... argTypes) { for (AnnotatedConstructor ac : _classInfo.getConstructors()) { // This list is already filtered to only include accessible /* (note: for now this is a redundant check; but in future * that may change; thus leaving here for now) */ if (ac.getParameterCount() == 1) { Class<?> actArg = ac.getRawParameterType(0); for (Class<?> expArg : argTypes) { if (expArg == actArg) { return ac.getAnnotated(); } } } } return null; } @Override public Method findFactoryMethod(Class<?>... expArgTypes) { // So, of all single-arg static methods: for (AnnotatedMethod am : _classInfo.getStaticMethods()) { if (isFactoryMethod(am)) { // And must take one of expected arg types (or supertype) Class<?> actualArgType = am.getRawParameterType(0); for (Class<?> expArgType : expArgTypes) { // And one that matches what we would pass in if (actualArgType.isAssignableFrom(expArgType)) { return am.getAnnotated(); } } } } return null; } protected boolean isFactoryMethod(AnnotatedMethod am) { /* First: return type must be compatible with the introspected class * (i.e. allowed to be sub-class, although usually is the same * class) */ Class<?> rt = am.getRawReturnType(); if (!getBeanClass().isAssignableFrom(rt)) { return false; } /* Also: must be a recognized factory method, meaning: * (a) marked with @JsonCreator annotation, or * (b) "valueOf" (at this point, need not be public) */ if (_annotationIntrospector.hasCreatorAnnotation(am)) { return true; } final String name = am.getName(); if ("valueOf".equals(name)) { return true; } // [Issue#208] Also accept "fromString()", if takes String or CharSequence if ("fromString".equals(name)) { if (1 == am.getParameterCount()) { Class<?> cls = am.getRawParameterType(0); if (cls == String.class || CharSequence.class.isAssignableFrom(cls)) { return true; } } } return false; } /** * @deprecated Since 2.4, use <code>findCreatorParameterNames()</code> instead. */ @Deprecated public List<String> findCreatorPropertyNames() { List<PropertyName> params = findCreatorParameterNames(); if (params.isEmpty()) { return Collections.emptyList(); } List<String> result = new ArrayList<String

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>, will collect serializable property * fields; if false, deserializable * * @return Ordered Map with logical property name as key, and * matching field as value. * * @deprecated Since 2.7.2, does not seem to be used? */ @Deprecated public LinkedHashMap<String,AnnotatedField> _findPropertyFields( Collection<String> ignoredProperties, boolean forSerialization) { LinkedHashMap<String,AnnotatedField> results = new LinkedHashMap<String,AnnotatedField>(); for (BeanPropertyDefinition property : _properties()) { AnnotatedField f = property.getField(); if (f != null) { String name = property.getName(); if (ignoredProperties != null) { if (ignoredProperties.contains(name)) { continue; } } results.put(name, f); } } return results; } /* /********************************************************** /* Helper methods, other /********************************************************** */ @SuppressWarnings("unchecked") public Converter<Object,Object> _createConverter(Object converterDef) { if (converterDef == null) { return null; } if (converterDef instanceof Converter<?,?>) { return (Converter<Object,Object>) converterDef; } if (!(converterDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned Converter definition of type " +converterDef.getClass().getName()+"; expected type Converter or Class<Converter> instead"); } Class<?> converterClass = (Class<?>)converterDef; // there are some known "no class" markers to consider too: if (converterClass == Converter.None.class || ClassUtil.isBogusClass(converterClass)) { return null; } if (!Converter.class.isAssignableFrom(converterClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +converterClass.getName()+"; expected Class<Converter>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); Converter<?,?> conv = (hi == null) ? null : hi.converterInstance(_config, _classInfo, converterClass); if (conv == null) { conv = (Converter<?,?>) ClassUtil.createInstance(converterClass, _config.canOverrideAccessModifiers()); } return (Converter<Object,Object>) conv; } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.util; import java.lang.annotation.Annotation; import java.lang.reflect.*; import java.util.*; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; public final class ClassUtil { private final static Class<?> CLS_OBJECT = Object.class; /* /********************************************************** /* Helper classes /********************************************************** */ /* 21-Feb-2016, tatu: Unfortunately `Collections.emptyIterator()` only * comes with JDK7, so we'll still have to include our bogus implementation * for as long as we want JDK6 runtime compatibility */ private final static class EmptyIterator<T> implements Iterator<T> { @Override public boolean hasNext() { return false; } @Override public T next() { throw new NoSuchElementException(); } @Override public void remove() { throw new UnsupportedOperationException(); } } private final static EmptyIterator<?> EMPTY_ITERATOR = new EmptyIterator<Object>(); /* /********************************************************** /* Simple factory methods /********************************************************** */ /** * @since 2.7 */ @SuppressWarnings("unchecked") public static <T> Iterator<T> emptyIterator() { // 21-Feb-2016, tatu: As per above, use a locally defined empty iterator // return Collections.emptyIterator(); return (Iterator<T>) EMPTY_ITERATOR; } /* /********************************************************** /* Methods that deal with inheritance /********************************************************** */ /** * Method that will find all sub-classes and implemented interfaces * of a given class or interface. Classes are listed in order of * precedence, starting with the immediate super-class, followed by * interfaces class directly declares to implemented, and then recursively * followed by parent of super-class and so forth. * Note that <code>Object.class</code> is not included in the list * regardless of whether <code>endBefore</code> argument is defined or not. * * @param endBefore Super-type to NOT include in results, if any; when * encountered, will be ignored (and no super types are checked). * * @since 2.7 */ public static List<JavaType> findSuperTypes(JavaType type, Class<?> endBefore, boolean addClassItself) { if ((type == null) || type.hasRawClass(endBefore) || type.hasRawClass(Object.class)) { return Collections.emptyList(); } List<JavaType> result = new ArrayList<JavaType>(8); _addSuperTypes(type, endBefore, result, addClassItself); return result; } /** * @since 2.

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>7 */ public static List<Class<?>> findRawSuperTypes(Class<?> cls, Class<?> endBefore, boolean addClassItself) { if ((cls == null) || (cls == endBefore) || (cls == Object.class)) { return Collections.emptyList(); } List<Class<?>> result = new ArrayList<Class<?>>(8); _addRawSuperTypes(cls, endBefore, result, addClassItself); return result; } /** * Method for finding all super classes (but not super interfaces) of given class, * starting with the immediate super class and ending in the most distant one. * Class itself is included if <code>addClassItself</code> is true. * * @since 2.7 */ public static List<Class<?>> findSuperClasses(Class<?> cls, Class<?> endBefore, boolean addClassItself) { List<Class<?>> result = new LinkedList<Class<?>>(); if ((cls != null) && (cls != endBefore)) { if (addClassItself) { result.add(cls); } while ((cls = cls.getSuperclass()) != null) { if (cls == endBefore) { break; } result.add(cls); } } return result; } @Deprecated // since 2.7 public static List<Class<?>> findSuperTypes(Class<?> cls, Class<?> endBefore) { return findSuperTypes(cls, endBefore, new ArrayList<Class<?>>(8)); } @Deprecated // since 2.7 public static List<Class<?>> findSuperTypes(Class<?> cls, Class<?> endBefore, List<Class<?>> result) { _addRawSuperTypes(cls, endBefore, result, false); return result; } private static void _addSuperTypes(JavaType type, Class<?> endBefore, Collection<JavaType> result, boolean addClassItself) { if (type == null) { return; } final Class<?> cls = type.getRawClass(); if (cls == endBefore || cls == Object.class) { return; } if (addClassItself) { if (result.contains(type)) { // already added, no need to check supers return; } result.add(type); } for (JavaType intCls : type.getInterfaces()) { _addSuperTypes(intCls, endBefore, result, true); } _addSuperTypes(type.getSuperClass(), endBefore, result, true); } private static void _addRawSuperTypes(Class<?> cls, Class<?> endBefore, Collection<Class<?>> result, boolean addClassItself) { if (cls == endBefore || cls == null || cls == Object.class) { return; } if

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> * not expose concrete method API that we could use to figure out * automatic Bean (property) based serialization. */ public static boolean isProxyType(Class<?> type) { // As per [databind#57], should NOT disqualify JDK proxy: /* // Then: well-known proxy (etc) classes if (Proxy.isProxyClass(type)) { return true; } */ String name = type.getName(); // Hibernate uses proxies heavily as well: if (name.startsWith("net.sf.cglib.proxy.") || name.startsWith("org.hibernate.proxy.")) { return true; } // Not one of known proxies, nope: return false; } /** * Helper method that checks if given class is a concrete one; * that is, not an interface or abstract class. */ public static boolean isConcrete(Class<?> type) { int mod = type.getModifiers(); return (mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0; } public static boolean isConcrete(Member member) { int mod = member.getModifiers(); return (mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0; } public static boolean isCollectionMapOrArray(Class<?> type) { if (type.isArray()) return true; if (Collection.class.isAssignableFrom(type)) return true; if (Map.class.isAssignableFrom(type)) return true; return false; } /* /********************************************************** /* Type name handling methods /********************************************************** */ /** * Helper method used to construct appropriate description * when passed either type (Class) or an instance; in latter * case, class of instance is to be used. */ public static String getClassDescription(Object classOrInstance) { if (classOrInstance == null) { return "unknown"; } Class<?> cls = (classOrInstance instanceof Class<?>) ? (Class<?>) classOrInstance : classOrInstance.getClass(); return cls.getName(); } /* /********************************************************** /* Class loading /********************************************************** */ /** * @deprecated Since 2.6, use method in {@link com.fasterxml.jackson.databind.type.TypeFactory}. */ @Deprecated public static Class<?> findClass(String className) throws ClassNotFoundException { // [JACKSON-597]: support primitive types (and void) if (className.indexOf('.') < 0) { if ("int".equals(className)) return Integer.TYPE; if ("long".equals(className)) return Long.TYPE; if ("float".equals(className)) return Float.TYPE; if ("double".equals(className)) return Double.TYPE; if ("boolean".equals(className

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS><?> cls) { // Caching does not seem worthwhile, as per profiling return isObjectOrPrimitive(cls) ? null : cls.getDeclaringClass(); } /** * @since 2.7 */ public static Type getGenericSuperclass(Class<?> cls) { return cls.getGenericSuperclass(); } /** * @since 2.7 */ public static Type[] getGenericInterfaces(Class<?> cls) { return _getMetadata(cls).getGenericInterfaces(); } /** * @since 2.7 */ public static Class<?> getEnclosingClass(Class<?> cls) { // Caching does not seem worthwhile, as per profiling return isObjectOrPrimitive(cls) ? null : cls.getEnclosingClass(); } private static Class<?>[] _interfaces(Class<?> cls) { return _getMetadata(cls).getInterfaces(); } private static ClassMetadata _getMetadata(Class<?> cls) { ClassMetadata md = sCached.get(cls); if (md == null) { md = new ClassMetadata(cls); // tiny optimization, but in case someone concurrently constructed it, // let's use that instance, to reduce extra concurrent work. ClassMetadata old = sCached.putIfAbsent(cls, md); if (old != null) { md = old; } } return md; } /* /********************************************************** /* Method type detection methods /********************************************************** */ /** * @deprecated Since 2.6 not used; may be removed before 3.x */ @Deprecated // since 2.6 public static boolean hasGetterSignature(Method m) { // First: static methods can't be getters if (Modifier.isStatic(m.getModifiers())) { return false; } // Must take no args Class<?>[] pts = m.getParameterTypes(); if (pts != null && pts.length != 0) { return false; } // Can't be a void method if (Void.TYPE == m.getReturnType()) { return false; } // Otherwise looks ok: return true; } /* /********************************************************** /* Exception handling /********************************************************** */ /** * Method that can be used to find the "root cause", innermost * of chained (wrapped) exceptions. */ public static Throwable getRootCause(Throwable t) { while (t.getCause() != null) { t = t.getCause(); } return t; } /** * Method that will unwrap root causes of given Throwable, and throw * the innermost {@link Exception} or {@link Error} as is. * This is useful in cases where mandatory wrapping is added, which * is often done by Reflection API. */

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>Modifiers()))) { ao.setAccessible(true); } } catch (SecurityException se) { /* 17-Apr-2009, tatu: Related to [JACKSON-101]: this can fail on * platforms like EJB and Google App Engine); so let's * only fail if we really needed it... */ if (!ao.isAccessible()) { Class<?> declClass = member.getDeclaringClass(); throw new IllegalArgumentException("Can not access "+member+" (from class "+declClass.getName()+"; failed to set access: "+se.getMessage()); } } //} } /* /********************************************************** /* Enum type detection /********************************************************** */ /** * Helper method that can be used to dynamically figure out * enumeration type of given {@link EnumSet}, without having * access to its declaration. * Code is needed to work around design flaw in JDK. */ public static Class<? extends Enum<?>> findEnumType(EnumSet<?> s) { // First things first: if not empty, easy to determine if (!s.isEmpty()) { return findEnumType(s.iterator().next()); } // Otherwise need to locate using an internal field return EnumTypeLocator.instance.enumTypeFor(s); } /** * Helper method that can be used to dynamically figure out * enumeration type of given {@link EnumSet}, without having * access to its declaration. * Code is needed to work around design flaw in JDK. */ public static Class<? extends Enum<?>> findEnumType(EnumMap<?,?> m) { if (!m.isEmpty()) { return findEnumType(m.keySet().iterator().next()); } // Otherwise need to locate using an internal field return EnumTypeLocator.instance.enumTypeFor(m); } /** * Helper method that can be used to dynamically figure out formal * enumeration type (class) for given enumeration. This is either * class of enum instance (for "simple" enumerations), or its * superclass (for enums with instance fields or methods) */ @SuppressWarnings("unchecked") public static Class<? extends Enum<?>> findEnumType(Enum<?> en) { // enums with "body" are sub-classes of the formal type Class<?> ec = en.getClass(); if (ec.getSuperclass() != Enum.class) { ec = ec.getSuperclass(); } return (Class<? extends Enum<?>>) ec; } /** * Helper method that can be used to dynamically figure out formal * enumeration type (class) for given class of an enumeration value. * This is either class of enum instance (for "simple" enumerations), * or its superclass (for enums with instance fields or methods) */

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> "") ? null : name; } // 19-Sep-2015, tatu: Bit of performance improvement, after finding this // in profile; maybe 5% in "wasteful" deserialization case public Class<?>[] getInterfaces() { Class<?>[] result = _interfaces; if (result == null) { result = _forClass.getInterfaces(); _interfaces = result; } return result; } // 30-Oct-2015, tatu: Minor performance boost too (5% or less) public Type[] getGenericInterfaces() { Type[] result = _genericInterfaces; if (result == null) { result = _forClass.getGenericInterfaces(); _genericInterfaces = result; } return result; } // 19-Sep-2015, tatu: Modest performance improvement, after finding this // in profile; maybe 2-3% in "wasteful" deserialization case public Annotation[] getDeclaredAnnotations() { Annotation[] result = _annotations; if (result == null) { result = isObjectOrPrimitive() ? NO_ANNOTATIONS : _forClass.getDeclaredAnnotations(); _annotations = result; } return result; } // 19-Sep-2015, tatu: Some performance improvement, after finding this // in profile; maybe 8-10% in "wasteful" deserialization case public Ctor[] getConstructors() { Ctor[] result = _constructors; if (result == null) { // Note: can NOT skip abstract classes as they may be used with mix-ins // and for regular use shouldn't really matter. if (_forClass.isInterface() || isObjectOrPrimitive()) { result = NO_CTORS; } else { Constructor<?>[] rawCtors = _forClass.getDeclaredConstructors(); final int len = rawCtors.length; result = new Ctor[len]; for (int i = 0; i < len; ++i) { result[i] = new Ctor(rawCtors[i]); } } _constructors = result; } return result; } // 21-Spe-2015, tatu: Surprisingly significant improvement (+10%)... public Field[] getDeclaredFields() { Field[] fields = _fields; if (fields == null) { fields = _forClass.getDeclaredFields(); _fields = fields; } return fields; } // 21-Spe-2015, tatu: Surprisingly significant improvement (+30%)... public Method[] getDeclaredMethods() { Method[] methods = _methods; if

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.jsontype.impl; import java.util.*; import com.fasterxml.jackson.databind.AnnotationIntrospector; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.introspect.*; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.fasterxml.jackson.databind.jsontype.SubtypeResolver; /** * Standard {@link SubtypeResolver} implementation. */ public class StdSubtypeResolver extends SubtypeResolver implements java.io.Serializable { private static final long serialVersionUID = 1L; protected LinkedHashSet<NamedType> _registeredSubtypes; public StdSubtypeResolver() { } /* /********************************************************** /* Subtype registration /********************************************************** */ @Override public void registerSubtypes(NamedType... types) { if (_registeredSubtypes == null) { _registeredSubtypes = new LinkedHashSet<NamedType>(); } for (NamedType type : types) { _registeredSubtypes.add(type); } } @Override public void registerSubtypes(Class<?>... classes) { NamedType[] types = new NamedType[classes.length]; for (int i = 0, len = classes.length; i < len; ++i) { types[i] = new NamedType(classes[i]); } registerSubtypes(types); } /* /********************************************************** /* Resolution by class (serialization) /********************************************************** */ @Override public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config, AnnotatedMember property, JavaType baseType) { final AnnotationIntrospector ai = config.getAnnotationIntrospector(); // for backwards compatibility, must allow null here: Class<?> rawBase = (baseType == null) ? property.getRawType() : baseType.getRawClass(); HashMap<NamedType, NamedType> collected = new HashMap<NamedType, NamedType>(); // start with registered subtypes (which have precedence) if (_registeredSubtypes != null) { for (NamedType subtype : _registeredSubtypes) { // is it a subtype of root type? if (rawBase.isAssignableFrom(subtype.getType())) { // yes AnnotatedClass curr = AnnotatedClass.constructWithoutSuperTypes(subtype.getType(), config); _collectAndResolve(curr, subtype, config, ai, collected); } } } // then annotated types for property itself Collection<NamedType> st = ai.findSubtypes(property); if (st != null) { for (NamedType nt : st) { AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(nt

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>.getType(), config); _collectAndResolve(ac, nt, config, ai, collected); } } NamedType rootType = new NamedType(rawBase, null); AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(rawBase, config); // and finally subtypes via annotations from base type (recursively) _collectAndResolve(ac, rootType, config, ai, collected); return new ArrayList<NamedType>(collected.values()); } @Override public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config, AnnotatedClass type) { final AnnotationIntrospector ai = config.getAnnotationIntrospector(); HashMap<NamedType, NamedType> subtypes = new HashMap<NamedType, NamedType>(); // [JACKSON-257] then consider registered subtypes (which have precedence over annotations) if (_registeredSubtypes != null) { Class<?> rawBase = type.getRawType(); for (NamedType subtype : _registeredSubtypes) { // is it a subtype of root type? if (rawBase.isAssignableFrom(subtype.getType())) { // yes AnnotatedClass curr = AnnotatedClass.constructWithoutSuperTypes(subtype.getType(), config); _collectAndResolve(curr, subtype, config, ai, subtypes); } } } // and then check subtypes via annotations from base type (recursively) NamedType rootType = new NamedType(type.getRawType(), null); _collectAndResolve(type, rootType, config, ai, subtypes); return new ArrayList<NamedType>(subtypes.values()); } /* /********************************************************** /* Resolution by class (deserialization) /********************************************************** */ @Override public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedMember property, JavaType baseType) { final AnnotationIntrospector ai = config.getAnnotationIntrospector(); Class<?> rawBase = (baseType == null) ? property.getRawType() : baseType.getRawClass(); // Need to keep track of classes that have been handled already Set<Class<?>> typesHandled = new HashSet<Class<?>>(); Map<String,NamedType> byName = new LinkedHashMap<String,NamedType>(); // start with lowest-precedence, which is from type hierarchy NamedType rootType = new NamedType(rawBase, null); AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(rawBase, config); _collectAndResolveByTypeId(ac, rootType, config, typesHandled, byName); // then with definitions from property Collection<NamedType> st = ai.findSubtypes(property); if (st != null) { for (NamedType nt : st) { ac = AnnotatedClass

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>.constructWithoutSuperTypes(nt.getType(), config); _collectAndResolveByTypeId(ac, nt, config, typesHandled, byName); } } // and finally explicit type registrations (highest precedence) if (_registeredSubtypes != null) { for (NamedType subtype : _registeredSubtypes) { // is it a subtype of root type? if (rawBase.isAssignableFrom(subtype.getType())) { // yes AnnotatedClass curr = AnnotatedClass.constructWithoutSuperTypes(subtype.getType(), config); _collectAndResolveByTypeId(curr, subtype, config, typesHandled, byName); } } } return _combineNamedAndUnnamed(typesHandled, byName); } @Override public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedClass type) { Set<Class<?>> typesHandled = new HashSet<Class<?>>(); Map<String,NamedType> byName = new LinkedHashMap<String,NamedType>(); NamedType rootType = new NamedType(type.getRawType(), null); _collectAndResolveByTypeId(type, rootType, config, typesHandled, byName); if (_registeredSubtypes != null) { Class<?> rawBase = type.getRawType(); for (NamedType subtype : _registeredSubtypes) { // is it a subtype of root type? if (rawBase.isAssignableFrom(subtype.getType())) { // yes AnnotatedClass curr = AnnotatedClass.constructWithoutSuperTypes(subtype.getType(), config); _collectAndResolveByTypeId(curr, subtype, config, typesHandled, byName); } } } return _combineNamedAndUnnamed(typesHandled, byName); } /* /********************************************************** /* Deprecated method overrides /********************************************************** */ @Override @Deprecated public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember property, MapperConfig<?> config, AnnotationIntrospector ai, JavaType baseType) { return collectAndResolveSubtypesByClass(config, property, baseType); } @Override @Deprecated public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass type, MapperConfig<?> config, AnnotationIntrospector ai) { return collectAndResolveSubtypesByClass(config, type); } /* /********************************************************** /* Internal methods /********************************************************** */ /** * Method called to find subtypes for a specific type (class), using * type (class) as the unique key (in case of conflicts). */ protected void _collectAndResolve(AnnotatedClass annotatedType, NamedType namedType, MapperConfig<?> config, AnnotationIntrospector ai, HashMap<NamedType, NamedType> collectedSubtypes) { if (!namedType.hasName()) { String name =

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> throws IOException, JsonParseException { return createParserUsingStream(new JsonFactory(), input, encoding); } protected JsonParser createParserUsingStream(JsonFactory f, String input, String encoding) throws IOException, JsonParseException { /* 23-Apr-2008, tatus: UTF-32 is not supported by JDK, have to * use our own codec too (which is not optimal since there's * a chance both encoder and decoder might have bugs, but ones * that cancel each other out or such) */ byte[] data; if (encoding.equalsIgnoreCase("UTF-32")) { data = encodeInUTF32BE(input); } else { data = input.getBytes(encoding); } InputStream is = new ByteArrayInputStream(data); return f.createParser(is); } /* /********************************************************** /* Additional assertion methods /********************************************************** */ protected void assertToken(JsonToken expToken, JsonToken actToken) { if (actToken != expToken) { fail("Expected token "+expToken+", current token "+actToken); } } protected void assertToken(JsonToken expToken, JsonParser jp) { assertToken(expToken, jp.getCurrentToken()); } protected void assertType(Object ob, Class<?> expType) { if (ob == null) { fail("Expected an object of type "+expType.getName()+", got null"); } Class<?> cls = ob.getClass(); if (!expType.isAssignableFrom(cls)) { fail("Expected type "+expType.getName()+", got "+cls.getName()); } } protected void assertValidLocation(JsonLocation location) { assertNotNull("Should have non-null location", location); assertTrue("Should have positive line number", location.getLineNr() > 0); } protected void verifyException(Throwable e, String... matches) { String msg = e.getMessage(); String lmsg = (msg == null) ? "" : msg.toLowerCase(); for (String match : matches) { String lmatch = match.toLowerCase(); if (lmsg.indexOf(lmatch) >= 0) { return; } } fail("Expected an exception with one of substrings ("+Arrays.asList(matches)+"): got one with message \""+msg+"\""); } /** * Method that gets textual contents of the current token using * available methods, and ensures results are consistent, before * returning them */ protected String getAndVerifyText(JsonParser jp) throws IOException, JsonParseException { // Ok, let's verify other accessors int actLen = jp.getTextLength(); char[] ch = jp.getTextCharacters(); String str2 = new String(ch, jp.getTextOffset(), actLen

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> if (ignorals != null && ignorals.length != 0) { HashSet<String> newIgnored = ArrayBuilders.setAndArray(contextual._ignorableProps, ignorals); contextual = contextual.withIgnorableProperties(newIgnored); } } // One more thing: are we asked to serialize POJO as array? JsonFormat.Shape shape = null; if (accessor != null) { JsonFormat.Value format = intr.findFormat((Annotated) accessor); if (format != null) { shape = format.getShape(); } } if (shape == null) { shape = _serializationShape; } if (shape == JsonFormat.Shape.ARRAY) { contextual = contextual.asArrayDeserializer(); } return contextual; } /** * Helper method called to see if given property is part of 'managed' property * pair (managed + back reference), and if so, handle resolution details. */ protected SettableBeanProperty _resolveManagedReferenceProperty(DeserializationContext ctxt, SettableBeanProperty prop) { String refName = prop.getManagedReferenceName(); if (refName == null) { return prop; } JsonDeserializer<?> valueDeser = prop.getValueDeserializer(); SettableBeanProperty backProp = valueDeser.findBackReference(refName); if (backProp == null) { throw new IllegalArgumentException("Can not handle managed/back reference '"+refName+"': no back reference property found from type " +prop.getType()); } // also: verify that type is compatible JavaType referredType = _beanType; JavaType backRefType = backProp.getType(); boolean isContainer = prop.getType().isContainerType(); if (!backRefType.getRawClass().isAssignableFrom(referredType.getRawClass())) { throw new IllegalArgumentException("Can not handle managed/back reference '"+refName+"': back reference type (" +backRefType.getRawClass().getName()+") not compatible with managed type (" +referredType.getRawClass().getName()+")"); } return new ManagedReferenceProperty(prop, refName, backProp, _classAnnotations, isContainer); } /** * Method that wraps given property with {@link ObjectIdReferenceProperty} * in case where object id resolution is required. */ protected SettableBeanProperty _resolvedObjectIdProperty(DeserializationContext ctxt, SettableBeanProperty prop) { ObjectIdInfo objectIdInfo = prop.getObjectIdInfo(); JsonDeserializer<Object> valueDeser = prop.getValueDeserializer(); ObjectIdReader objectIdReader = valueDeser.getObjectIdReader(); if (objectIdInfo == null && objectIdReader == null) { return prop; } return new ObjectIdReferenceProperty(prop, objectIdInfo); } /** * Helper

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> static Class<?> CLASS_DOM_DOCUMENT; static { Class<?> doc = null, node = null; try { node = org.w3c.dom.Node.class; doc = org.w3c.dom.Document.class; } catch (Exception e) { // not optimal but will do System.err.println("WARNING: could not load DOM Node and/or Document classes"); } CLASS_DOM_NODE = node; CLASS_DOM_DOCUMENT = doc; } // // But Java7 type(s) may or may not be; dynamic lookup should be fine, still // // (note: also assume it comes from JDK so that ClassLoader issues with OSGi // // can, I hope, be avoided?) private final static Class<?> CLASS_JAVA7_PATH; static { Class<?> cls = null; try { cls = Class.forName("java.nio.file.Path"); } catch (Exception e) { // not optimal but will do System.err.println("WARNING: could not load Java7 Path class"); } CLASS_JAVA7_PATH = cls; } public final static OptionalHandlerFactory instance = new OptionalHandlerFactory(); protected OptionalHandlerFactory() { } /* /********************************************************** /* Public API /********************************************************** */ public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) { final Class<?> rawType = type.getRawClass(); if ((CLASS_JAVA7_PATH != null) && CLASS_JAVA7_PATH.isAssignableFrom(rawType)) { return ToStringSerializer.instance; } if ((CLASS_DOM_NODE != null) && CLASS_DOM_NODE.isAssignableFrom(rawType)) { return (JsonSerializer<?>) instantiate(SERIALIZER_FOR_DOM_NODE); } String className = rawType.getName(); String factoryName; if (className.startsWith(PACKAGE_PREFIX_JAVAX_XML) || hasSuperClassStartingWith(rawType, PACKAGE_PREFIX_JAVAX_XML)) { factoryName = SERIALIZERS_FOR_JAVAX_XML; } else { return null; } Object ob = instantiate(factoryName); if (ob == null) { // could warn, if we had logging system (j.u.l?) return null; } return ((Serializers) ob).findSerializer(config, type, beanDesc); } public JsonDeserializer<?> findDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { final Class<?> rawType = type.getRawClass(); if ((CLASS_JAVA7_PATH != null) && CLASS_JAVA7_PATH.isAssignableFrom(rawType)) { return (JsonDeserializer<?>) instantiate(DESERIALIZER_

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>FOR_PATH); } if ((CLASS_DOM_NODE != null) && CLASS_DOM_NODE.isAssignableFrom(rawType)) { return (JsonDeserializer<?>) instantiate(DESERIALIZER_FOR_DOM_NODE); } if ((CLASS_DOM_DOCUMENT != null) && CLASS_DOM_DOCUMENT.isAssignableFrom(rawType)) { return (JsonDeserializer<?>) instantiate(DESERIALIZER_FOR_DOM_DOCUMENT); } String className = rawType.getName(); String factoryName; if (className.startsWith(PACKAGE_PREFIX_JAVAX_XML) || hasSuperClassStartingWith(rawType, PACKAGE_PREFIX_JAVAX_XML)) { factoryName = DESERIALIZERS_FOR_JAVAX_XML; } else { return null; } Object ob = instantiate(factoryName); if (ob == null) { // could warn, if we had logging system (j.u.l?) return null; } return ((Deserializers) ob).findBeanDeserializer(type, config, beanDesc); } /* /********************************************************** /* Internal helper methods /********************************************************** */ private Object instantiate(String className) { try { return Class.forName(className).newInstance(); } catch (LinkageError e) { } // too many different kinds to enumerate here: catch (Exception e) { } return null; } /** * Since 2.7 we only need to check for class extension, as all implemented * types are classes, not interfaces. This has performance implications for * some cases, as we do not need to go over interfaces implemented, just * superclasses * * @since 2.7 */ private boolean hasSuperClassStartingWith(Class<?> rawType, String prefix) { for (Class<?> supertype = rawType.getSuperclass(); supertype != null; supertype = supertype.getSuperclass()) { if (supertype == Object.class) { return false; } if (supertype.getName().startsWith(prefix)) { return true; } } return false; } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> { gen.writeFieldName(String.valueOf(date.getTime())); } else { gen.writeFieldName(_dateFormat().format(date)); } } public final void defaultSerializeNull(JsonGenerator jgen) throws IOException { if (_stdNullValueSerializer) { // minor perf optimization jgen.writeNull(); } else { _nullValueSerializer.serialize(null, jgen, this); } } /* /******************************************************** /* Error reporting /******************************************************** */ /** * @since 2.6 */ public JsonMappingException mappingException(String message, Object... args) { if (args != null && args.length > 0) { message = String.format(message, args); } return JsonMappingException.from(this, message); } /* /******************************************************** /* Helper methods /******************************************************** */ protected void _reportIncompatibleRootType(Object value, JavaType rootType) throws IOException { // One special case: allow primitive/wrapper type coercion if (rootType.isPrimitive()) { Class<?> wrapperType = ClassUtil.wrapperType(rootType.getRawClass()); // If it's just difference between wrapper, primitive, let it slide if (wrapperType.isAssignableFrom(value.getClass())) { return; } } throw JsonMappingException.from(this, "Incompatible types: declared root type ("+rootType+") vs " +value.getClass().getName()); } /** * Method that will try to find a serializer, either from cache * or by constructing one; but will not return an "unknown" serializer * if this can not be done but rather returns null. * * @return Serializer if one can be found, null if not. */ protected JsonSerializer<Object> _findExplicitUntypedSerializer(Class<?> runtimeType) throws JsonMappingException { // Fast lookup from local lookup thingy works? JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(runtimeType); if (ser == null) { // If not, maybe shared map already has it? ser = _serializerCache.untypedValueSerializer(runtimeType); if (ser == null) { ser = _createAndCacheUntypedSerializer(runtimeType); } } /* 18-Sep-2014, tatu: This is unfortunate patch over related change * that pushes creation of "unknown type" serializer deeper down * in BeanSerializerFactory; as a result, we need to "undo" creation * here. */ if (isUnknownTypeSerializer(ser)) { return null; } return ser; } /* /********************************************************** /* Low-level methods for actually constructing and initializing /* serializers /********************************************************** */ /**

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>accumulator = new ArrayList<MapReferring>(); public MapReferringAccumulator(Class<?> valueType, Map<Object, Object> result) { _valueType = valueType; _result = result; } public void put(Object key, Object value) { if (_accumulator.isEmpty()) { _result.put(key, value); } else { MapReferring ref = _accumulator.get(_accumulator.size() - 1); ref.next.put(key, value); } } public Referring handleUnresolvedReference(UnresolvedForwardReference reference, Object key) { MapReferring id = new MapReferring(this, reference, _valueType, key); _accumulator.add(id); return id; } public void resolveForwardReference(Object id, Object value) throws IOException { Iterator<MapReferring> iterator = _accumulator.iterator(); // Resolve ordering after resolution of an id. This means either: // 1- adding to the result map in case of the first unresolved id. // 2- merge the content of the resolved id with its previous unresolved id. Map<Object,Object> previous = _result; while (iterator.hasNext()) { MapReferring ref = iterator.next(); if (ref.hasId(id)) { iterator.remove(); previous.put(ref.key, value); previous.putAll(ref.next); return; } previous = ref.next; } throw new IllegalArgumentException("Trying to resolve a forward reference with id [" + id + "] that wasn't previously seen as unresolved."); } } /** * Helper class to maintain processing order of value. * The resolved object associated with {@link #key} comes before the values in * {@link #next}. */ final static class MapReferring extends Referring { private final MapReferringAccumulator _parent; public final Map<Object, Object> next = new LinkedHashMap<Object, Object>(); public final Object key; MapReferring(MapReferringAccumulator parent, UnresolvedForwardReference ref, Class<?> valueType, Object key) { super(ref, valueType); _parent = parent; this.key = key; } @Override public void handleResolvedForwardReference(Object id, Object value) throws IOException { _parent.resolveForwardReference(id, value); } } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> @Override @Deprecated public String containedTypeName(int index) { return _bindings.getBoundName(index); } @Override public JavaType getSuperClass() { return _superClass; } @Override public List<JavaType> getInterfaces() { if (_superInterfaces == null) { return Collections.emptyList(); } switch (_superInterfaces.length) { case 0: return Collections.emptyList(); case 1: return Collections.singletonList(_superInterfaces[0]); } return Arrays.asList(_superInterfaces); } @Override public final JavaType findSuperType(Class<?> rawTarget) { if (rawTarget == _class) { return this; } // Check super interfaces first: if (rawTarget.isInterface() && (_superInterfaces != null)) { for (int i = 0, count = _superInterfaces.length; i < count; ++i) { JavaType type = _superInterfaces[i].findSuperType(rawTarget); if (type != null) { return type; } } } // and if not found, super class and its supertypes if (_superClass != null) { JavaType type = _superClass.findSuperType(rawTarget); if (type != null) { return type; } } return null; } @Override public JavaType[] findTypeParameters(Class<?> expType) { JavaType match = findSuperType(expType); if (match == null) { return NO_TYPES; } return match.getBindings().typeParameterArray(); } /* /********************************************************** /* JsonSerializable base implementation /********************************************************** */ @Override public void serializeWithType(JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException { typeSer.writeTypePrefixForScalar(this, gen); this.serialize(gen, provider); typeSer.writeTypeSuffixForScalar(this, gen); } @Override public void serialize(JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException { gen.writeString(toCanonical()); } /* /********************************************************** /* Methods for sub-classes to use /********************************************************** */ /** * @param trailingSemicolon Whether to add trailing semicolon for non-primitive * (reference) types or not */ protected static StringBuilder _classSignature(Class<?> cls, StringBuilder sb, boolean trailingSemicolon) { if (cls.isPrimitive()) { if (cls == Boolean.TYPE) { sb.append('Z'); } else if (cls == Byte.TYPE) { sb.append('B'); } else if (cls == Short.TYPE) {

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>config, forSerialization, type, ac, mutatorPrefix); } /** * Method called to see if type is one of core JDK types * that we have cached for efficiency. */ protected BasicBeanDescription _findStdTypeDesc(JavaType type) { Class<?> cls = type.getRawClass(); if (cls.isPrimitive()) { if (cls == Boolean.TYPE) { return BOOLEAN_DESC; } if (cls == Integer.TYPE) { return INT_DESC; } if (cls == Long.TYPE) { return LONG_DESC; } } else { if (cls == String.class) { return STRING_DESC; } } return null; } /** * Helper method used to decide whether we can omit introspection * for members (methods, fields, constructors); we may do so for * a limited number of container types JDK provides. */ protected boolean _isStdJDKCollection(JavaType type) { if (!type.isContainerType() || type.isArrayType()) { return false; } Class<?> raw = type.getRawClass(); String pkgName = ClassUtil.getPackageName(raw); if (pkgName != null) { if (pkgName.startsWith("java.lang") || pkgName.startsWith("java.util")) { /* 23-Sep-2014, tatu: Should we be conservative here (minimal number * of matches), or ambitious? Let's do latter for now. */ if (Collection.class.isAssignableFrom(raw) || Map.class.isAssignableFrom(raw)) { return true; } } } return false; } protected BasicBeanDescription _findStdJdkCollectionDesc(MapperConfig<?> cfg, JavaType type) { if (_isStdJDKCollection(type)) { AnnotatedClass ac = AnnotatedClass.construct(type, cfg); return BasicBeanDescription.forOtherUse(cfg, type, ac); } return null; } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.deser; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.impl.ObjectIdReader; import com.fasterxml.jackson.databind.deser.impl.ReadableObjectId; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; /** * Deserializer only used for abstract types used as placeholders during polymorphic * type handling deserialization. If so, there is no real deserializer associated * with nominal type, just {@link TypeDeserializer}; and any calls that do not * pass such resolver will result in an error. */ public class AbstractDeserializer extends JsonDeserializer<Object> implements java.io.Serializable { private static final long serialVersionUID = 1L; protected final JavaType _baseType; protected final ObjectIdReader _objectIdReader; protected final Map<String, SettableBeanProperty> _backRefProperties; // support for "native" types, which require special care: protected final boolean _acceptString; protected final boolean _acceptBoolean; protected final boolean _acceptInt; protected final boolean _acceptDouble; public AbstractDeserializer(BeanDeserializerBuilder builder, BeanDescription beanDesc, Map<String, SettableBeanProperty> backRefProps) { _baseType = beanDesc.getType(); _objectIdReader = builder.getObjectIdReader(); _backRefProperties = backRefProps; Class<?> cls = _baseType.getRawClass(); _acceptString = cls.isAssignableFrom(String.class); _acceptBoolean = (cls == Boolean.TYPE) || cls.isAssignableFrom(Boolean.class); _acceptInt = (cls == Integer.TYPE) || cls.isAssignableFrom(Integer.class); _acceptDouble = (cls == Double.TYPE) || cls.isAssignableFrom(Double.class); } protected AbstractDeserializer(BeanDescription beanDesc) { _baseType = beanDesc.getType(); _objectIdReader = null; _backRefProperties = null; Class<?> cls = _baseType.getRawClass(); _acceptString = cls.isAssignableFrom(String.class); _acceptBoolean = (cls == Boolean.TYPE) || cls.isAssignableFrom(Boolean.class); _acceptInt = (cls == Integer.TYPE) || cls.isAssignableFrom(Integer.class); _acceptDouble = (cls == Double.TYPE) || cls.isAssignableFrom(Double.class); } /** * Factory method used when constructing instances for non-POJO types, like * {@link java.util.Map}s. * * @since 2.3 */ public static AbstractDeserializer constructForNonPOJO(BeanDescription beanDesc) { return new AbstractDeserializer(beanDesc); }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> * as ignored. */ protected void _removeUnwantedProperties(Map<String, POJOPropertyBuilder> props) { Iterator<POJOPropertyBuilder> it = props.values().iterator(); while (it.hasNext()) { POJOPropertyBuilder prop = it.next(); // First: if nothing visible, just remove altogether if (!prop.anyVisible()) { it.remove(); continue; } // Otherwise, check ignorals if (prop.anyIgnorals()) { // first: if one or more ignorals, and no explicit markers, remove the whole thing if (!prop.isExplicitlyIncluded()) { it.remove(); _collectIgnorals(prop.getName()); continue; } // otherwise just remove ones marked to be ignored prop.removeIgnored(); if (!_forSerialization && !prop.couldDeserialize()) { _collectIgnorals(prop.getName()); } } } } /** * Method called to further get rid of unwanted individual accessors, * based on read/write settings and rules for "pulling in" accessors * (or not). */ protected void _removeUnwantedAccessor(Map<String, POJOPropertyBuilder> props) { final boolean inferMutators = _config.isEnabled(MapperFeature.INFER_PROPERTY_MUTATORS); Iterator<POJOPropertyBuilder> it = props.values().iterator(); while (it.hasNext()) { POJOPropertyBuilder prop = it.next(); prop.removeNonVisible(inferMutators); } } /** * Helper method called to add explicitly ignored properties to a list * of known ignored properties; this helps in proper reporting of * errors. */ private void _collectIgnorals(String name) { if (!_forSerialization) { if (_ignoredPropertyNames == null) { _ignoredPropertyNames = new HashSet<String>(); } _ignoredPropertyNames.add(name); } } /* /********************************************************** /* Internal methods; renaming properties /********************************************************** */ protected void _renameProperties(Map<String, POJOPropertyBuilder> props) { // With renaming need to do in phases: first, find properties to rename Iterator<Map.Entry<String,POJOPropertyBuilder>> it = props.entrySet().iterator(); LinkedList<POJOPropertyBuilder> renamed = null; while (it.hasNext()) { Map.Entry<String, POJOPropertyBuilder> entry = it.next(); POJOPropertyBuilder prop = entry.getValue(); Collection<PropertyName> l = prop.findExplicitNames(); // no explicit names? Implicit one is fine as is if (l.isEmpty()) { continue; } it.remove(); // need to replace with one or more renamed if (re

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>named == null) { renamed = new LinkedList<POJOPropertyBuilder>(); } // simple renaming? Just do it if (l.size() == 1) { PropertyName n = l.iterator().next(); renamed.add(prop.withName(n)); continue; } // but this may be problematic... renamed.addAll(prop.explode(l)); /* String newName = prop.findNewName(); if (newName != null) { if (renamed == null) { renamed = new LinkedList<POJOPropertyBuilder>(); } prop = prop.withSimpleName(newName); renamed.add(prop); it.remove(); } */ } // and if any were renamed, merge back in... if (renamed != null) { for (POJOPropertyBuilder prop : renamed) { String name = prop.getName(); POJOPropertyBuilder old = props.get(name); if (old == null) { props.put(name, prop); } else { old.addAll(prop); } // replace the creatorProperty too, if there is one _updateCreatorProperty(prop, _creatorProperties); } } } protected void _renameUsing(Map<String, POJOPropertyBuilder> propMap, PropertyNamingStrategy naming) { POJOPropertyBuilder[] props = propMap.values().toArray(new POJOPropertyBuilder[propMap.size()]); propMap.clear(); for (POJOPropertyBuilder prop : props) { PropertyName fullName = prop.getFullName(); String rename = null; // As per [databind#428] need to skip renaming if property has // explicitly defined name, unless feature is enabled if (!prop.isExplicitlyNamed() || _config.isEnabled(MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING)) { if (_forSerialization) { if (prop.hasGetter()) { rename = naming.nameForGetterMethod(_config, prop.getGetter(), fullName.getSimpleName()); } else if (prop.hasField()) { rename = naming.nameForField(_config, prop.getField(), fullName.getSimpleName()); } } else { if (prop.hasSetter()) { rename = naming.nameForSetterMethod(_config, prop.getSetter(), fullName.getSimpleName()); } else if (prop.hasConstructorParameter()) { rename = naming.nameForConstructorParameter(_config, prop.getConstructorParameter(), fullName.getSimpleName()); } else if (prop.hasField()) { rename = naming.nameForField(_config, prop.getField(), fullName.getSimpleName()); } else if (prop.hasGetter()) { /* Plus, when getter-as-setter is used, need to convert that too.. * (should we verify that's

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> enabled? For now, assume it's ok always) */ rename = naming.nameForGetterMethod(_config, prop.getGetter(), fullName.getSimpleName()); } } } final String simpleName; if (rename != null && !fullName.hasSimpleName(rename)) { prop = prop.withSimpleName(rename); simpleName = rename; } else { simpleName = fullName.getSimpleName(); } /* As per [JACKSON-687], need to consider case where there may already be * something in there... */ POJOPropertyBuilder old = propMap.get(simpleName); if (old == null) { propMap.put(simpleName, prop); } else { old.addAll(prop); } // replace the creatorProperty too, if there is one _updateCreatorProperty(prop, _creatorProperties); } } protected void _renameWithWrappers(Map<String, POJOPropertyBuilder> props) { /* 11-Sep-2012, tatu: To support 'MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME', * need another round of renaming... */ Iterator<Map.Entry<String,POJOPropertyBuilder>> it = props.entrySet().iterator(); LinkedList<POJOPropertyBuilder> renamed = null; while (it.hasNext()) { Map.Entry<String, POJOPropertyBuilder> entry = it.next(); POJOPropertyBuilder prop = entry.getValue(); AnnotatedMember member = prop.getPrimaryMember(); if (member == null) { continue; } PropertyName wrapperName = _annotationIntrospector.findWrapperName(member); // One trickier part (wrt [Issue#24] of JAXB annotations: wrapper that // indicates use of actual property... But hopefully has been taken care // of previously if (wrapperName == null || !wrapperName.hasSimpleName()) { continue; } if (!wrapperName.equals(prop.getFullName())) { if (renamed == null) { renamed = new LinkedList<POJOPropertyBuilder>(); } prop = prop.withName(wrapperName); renamed.add(prop); it.remove(); } } // and if any were renamed, merge back in... if (renamed != null) { for (POJOPropertyBuilder prop : renamed) { String name = prop.getName(); POJOPropertyBuilder old = props.get(name); if (old == null) { props.put(name, prop); } else { old.addAll(prop); } } } } /* /********************************************************** /* Overridable internal methods, sorting, other stuff /********************************************************** */ /* First, order by [JACK

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>PropertyBuilder prop : _creatorProperties) { sorted.put(prop.getName(), prop); } cr = sorted.values(); } else { cr = _creatorProperties; } for (POJOPropertyBuilder prop : cr) { ordered.put(prop.getName(), prop); } } // And finally whatever is left (trying to put again will not change ordering) ordered.putAll(all); props.clear(); props.putAll(ordered); } /* /********************************************************** /* Internal methods; helpers /********************************************************** */ protected void reportProblem(String msg) { throw new IllegalArgumentException("Problem with definition of "+_classDef+": "+msg); } protected POJOPropertyBuilder _property(Map<String, POJOPropertyBuilder> props, PropertyName name) { return _property(props, name.getSimpleName()); } // !!! TODO: deprecate, require use of PropertyName protected POJOPropertyBuilder _property(Map<String, POJOPropertyBuilder> props, String implName) { POJOPropertyBuilder prop = props.get(implName); if (prop == null) { prop = new POJOPropertyBuilder(_config, _annotationIntrospector, _forSerialization, PropertyName.construct(implName)); props.put(implName, prop); } return prop; } private PropertyNamingStrategy _findNamingStrategy() { Object namingDef = (_annotationIntrospector == null)? null : _annotationIntrospector.findNamingStrategy(_classDef); if (namingDef == null) { return _config.getPropertyNamingStrategy(); } if (namingDef instanceof PropertyNamingStrategy) { return (PropertyNamingStrategy) namingDef; } /* Alas, there's no way to force return type of "either class * X or Y" -- need to throw an exception after the fact */ if (!(namingDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned PropertyNamingStrategy definition of type " +namingDef.getClass().getName()+"; expected type PropertyNamingStrategy or Class<PropertyNamingStrategy> instead"); } Class<?> namingClass = (Class<?>)namingDef; // 09-Nov-2015, tatu: Need to consider pseudo-value of STD, which means "use default" if (namingClass == PropertyNamingStrategy.class) { return null; } if (!PropertyNamingStrategy.class.isAssignableFrom(namingClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +namingClass.getName()+"; expected Class<PropertyNamingStrategy>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); if (hi != null) { PropertyNamingStrategy pns = hi.namingStrategyInstance(_config, _classDef, naming

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> public boolean isCollectionLikeType() { return true; } @Override public JavaType getContentType() { return _elementType; } @Override public Object getContentValueHandler() { return _elementType.getValueHandler(); } @Override public Object getContentTypeHandler() { return _elementType.getTypeHandler(); } @Override public StringBuilder getErasedSignature(StringBuilder sb) { return _classSignature(_class, sb, true); } @Override public StringBuilder getGenericSignature(StringBuilder sb) { _classSignature(_class, sb, false); sb.append('<'); _elementType.getGenericSignature(sb); sb.append(">;"); return sb; } @Override protected String buildCanonicalName() { StringBuilder sb = new StringBuilder(); sb.append(_class.getName()); if (_elementType != null) { sb.append('<'); sb.append(_elementType.toCanonical()); sb.append('>'); } return sb.toString(); } /* /********************************************************** /* Extended API /********************************************************** */ /** * Method that can be used for checking whether this type is a * "real" Collection type; meaning whether it represents a parameterized * subtype of {@link java.util.Collection} or just something that acts * like one. */ public boolean isTrueCollectionType() { return Collection.class.isAssignableFrom(_class); } /* /********************************************************** /* Standard methods /********************************************************** */ @Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) return false; CollectionLikeType other = (CollectionLikeType) o; return (_class == other._class) && _elementType.equals(other._elementType); } @Override public String toString() { return "[collection-like type; class "+_class.getName()+", contains "+_elementType+"]"; } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> also: if we start from untyped, not much to save do { // bogus loop to be able to break if (rawBase == Object.class) { newType = _fromClass(null, subclass, TypeBindings.emptyBindings()); break; } if (!rawBase.isAssignableFrom(subclass)) { throw new IllegalArgumentException(String.format( "Class %s not subtype of %s", subclass.getName(), baseType)); } // A few special cases where we can simplify handling: // (1) Original target type has no generics -- just resolve subtype if (baseType.getBindings().isEmpty()) { newType = _fromClass(null, subclass, TypeBindings.emptyBindings()); break; } // (2) A small set of "well-known" List/Map subtypes where can take a short-cut if (baseType.isContainerType()) { if (baseType.isMapLikeType()) { if ((subclass == HashMap.class) || (subclass == LinkedHashMap.class) || (subclass == EnumMap.class) || (subclass == TreeMap.class)) { newType = _fromClass(null, subclass, TypeBindings.create(subclass, baseType.getKeyType(), baseType.getContentType())); break; } } else if (baseType.isCollectionLikeType()) { if ((subclass == ArrayList.class) || (subclass == LinkedList.class) || (subclass == HashSet.class) || (subclass == TreeSet.class)) { newType = _fromClass(null, subclass, TypeBindings.create(subclass, baseType.getContentType())); break; } // 29-Oct-2015, tatu: One further shortcut: there are variants of `EnumSet`, // but they are impl details and we basically do not care... if (rawBase == EnumSet.class) { return baseType; } } } // (3) Sub-class does not take type parameters -- just resolve subtype if (subclass.getTypeParameters().length == 0) { newType = _fromClass(null, subclass, TypeBindings.emptyBindings()); break; } // If not, we'll need to do more thorough forward+backwards resolution. Sigh. // !!! TODO (as of 28-Jan-2016, at least) // 20-Oct-2015, tatu: Container, Map-types somewhat special. There is // a way to fully resolve and merge hierarchies; but that gets expensive // so let's, for now, try to create close-enough approximation that // is not 100% same, structurally, but has equivalent information for // our specific neeeds

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> * there may be need for some additional work-arounds. * * @param superClass * * @since 2.7 */ public JavaType constructGeneralizedType(JavaType baseType, Class<?> superClass) { // simple optimization to avoid costly introspection if type-erased type does NOT differ final Class<?> rawBase = baseType.getRawClass(); if (rawBase == superClass) { return baseType; } JavaType superType = baseType.findSuperType(superClass); if (superType == null) { // Most likely, caller did not verify sub/super-type relationship if (!superClass.isAssignableFrom(rawBase)) { throw new IllegalArgumentException(String.format( "Class %s not a super-type of %s", superClass.getName(), baseType)); } // 01-Nov-2015, tatu: Should never happen, but ch throw new IllegalArgumentException(String.format( "Internal error: class %s not included as super-type for %s", superClass.getName(), baseType)); } return superType; } /** * Factory method for constructing a {@link JavaType} out of its canonical * representation (see {@link JavaType#toCanonical()}). * * @param canonical Canonical string representation of a type * * @throws IllegalArgumentException If canonical representation is malformed, * or class that type represents (including its generic parameters) is * not found */ public JavaType constructFromCanonical(String canonical) throws IllegalArgumentException { return _parser.parse(canonical); } /** * Method that is to figure out actual type parameters that given * class binds to generic types defined by given (generic) * interface or class. * This could mean, for example, trying to figure out * key and value types for Map implementations. * * @param type Sub-type (leaf type) that implements <code>expType</code> */ public JavaType[] findTypeParameters(JavaType type, Class<?> expType) { JavaType match = type.findSuperType(expType); if (match == null) { return NO_TYPES; } return match.getBindings().typeParameterArray(); } /** * @deprecated Since 2.7 resolve raw type first, then find type parameters */ @Deprecated // since 2.7 public JavaType[] findTypeParameters(Class<?> clz, Class<?> expType, TypeBindings bindings) { return findTypeParameters(constructType(clz, bindings), expType); } /** * @deprecated Since 2.7 resolve raw type first, then find type parameters */ @Deprecated // since 2.7 public JavaType[] findTypeParameters(Class<?> clz, Class<?> exp

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>Type) { return findTypeParameters(constructType(clz), expType); } /** * Method that can be called to figure out more specific of two * types (if they are related; that is, one implements or extends the * other); or if not related, return the primary type. * * @param type1 Primary type to consider * @param type2 Secondary type to consider * * @since 2.2 */ public JavaType moreSpecificType(JavaType type1, JavaType type2) { if (type1 == null) { return type2; } if (type2 == null) { return type1; } Class<?> raw1 = type1.getRawClass(); Class<?> raw2 = type2.getRawClass(); if (raw1 == raw2) { return type1; } // TODO: maybe try sub-classing, to retain generic types? if (raw1.isAssignableFrom(raw2)) { return type2; } return type1; } /* /********************************************************** /* Public factory methods /********************************************************** */ public JavaType constructType(Type type) { return _fromAny(null, type, EMPTY_BINDINGS); } public JavaType constructType(Type type, TypeBindings bindings) { return _fromAny(null, type, bindings); } public JavaType constructType(TypeReference<?> typeRef) { // 19-Oct-2015, tatu: Simpler variant like so should work return _fromAny(null, typeRef.getType(), EMPTY_BINDINGS); // but if not, due to funky sub-classing, type variables, what follows // is a more complete processing a la Java ClassMate. /* final Class<?> refdRawType = typeRef.getClass(); JavaType type = _fromClass(null, refdRawType, EMPTY_BINDINGS); JavaType genType = type.findSuperType(TypeReference.class); if (genType == null) { // sanity check; shouldn't occur throw new IllegalArgumentException("Unparameterized GenericType instance ("+refdRawType.getName()+")"); } TypeBindings b = genType.getBindings(); JavaType[] params = b.typeParameterArray(); if (params.length == 0) { throw new IllegalArgumentException("Unparameterized GenericType instance ("+refdRawType.getName()+")"); } return params[0]; */ } /** * @deprecated Since 2.7 (accidentally removed in 2.7.0; added back in 2.7.1) */ @Deprecated public JavaType constructType(Type type, Class<?> contextClass) { TypeBindings bindings = (contextClass ==

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> NOT adding this to 'ignored': builder.addIgnorable(propName); } } } final boolean useGettersAsSetters = (ctxt.isEnabled(MapperFeature.USE_GETTERS_AS_SETTERS) && ctxt.isEnabled(MapperFeature.AUTO_DETECT_GETTERS)); // Ok: let's then filter out property definitions List<BeanPropertyDefinition> propDefs = filterBeanProps(ctxt, beanDesc, builder, beanDesc.findProperties(), ignored); // After which we can let custom code change the set if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { propDefs = mod.updateProperties(ctxt.getConfig(), beanDesc, propDefs); } } // At which point we still have all kinds of properties; not all with mutators: for (BeanPropertyDefinition propDef : propDefs) { SettableBeanProperty prop = null; /* 18-Oct-2013, tatu: Although constructor parameters have highest precedence, * we need to do linkage (as per [databind#318]), and so need to start with * other types, and only then create constructor parameter, if any. */ if (propDef.hasSetter()) { JavaType propertyType = propDef.getSetter().getParameterType(0); prop = constructSettableProperty(ctxt, beanDesc, propDef, propertyType); } else if (propDef.hasField()) { JavaType propertyType = propDef.getField().getType(); prop = constructSettableProperty(ctxt, beanDesc, propDef, propertyType); } else if (useGettersAsSetters && propDef.hasGetter()) { /* May also need to consider getters * for Map/Collection properties; but with lowest precedence */ AnnotatedMethod getter = propDef.getGetter(); // should only consider Collections and Maps, for now? Class<?> rawPropertyType = getter.getRawType(); if (Collection.class.isAssignableFrom(rawPropertyType) || Map.class.isAssignableFrom(rawPropertyType)) { prop = constructSetterlessProperty(ctxt, beanDesc, propDef); } } // 25-Sep-2014, tatu: No point in finding constructor parameters for abstract types // (since they are never used anyway) if (isConcrete && propDef.hasConstructorParameter()) { /* [JACKSON-700] If property is passed via constructor parameter, we must * handle things in special way. Not sure what is the most optimal way... * for now, let's just call a (new) method in builder, which does nothing. */ // but let's call a method just to allow custom builders to be aware... final String name

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>Generator gen, Object value, JavaType rootType) throws IOException { if (value == null) { _serializeNull(gen); return; } // Let's ensure types are compatible at this point if (!rootType.getRawClass().isAssignableFrom(value.getClass())) { _reportIncompatibleRootType(value, rootType); } // root value, not reached via property: JsonSerializer<Object> ser = findTypedValueSerializer(rootType, true, null); // Ok: should we wrap result in an additional property ("root name")? final boolean wrap; PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified // [JACKSON-163] wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = _config.findRootName(value.getClass()); gen.writeFieldName(pname.simpleAsEncoded(_config)); } } else if (rootName.isEmpty()) { wrap = false; } else { // [JACKSON-764] // empty String means explicitly disabled; non-empty that it is enabled wrap = true; gen.writeStartObject(); gen.writeFieldName(rootName.getSimpleName()); } try { ser.serialize(value, gen, this); if (wrap) { gen.writeEndObject(); } } catch (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw JsonMappingException.from(gen, msg, e); } } /** * The method to be called by {@link ObjectWriter} * for serializing given value (assumed to be of specified root type, * instead of runtime type of value), when it may know specific * {@link JsonSerializer} to use. * * @param rootType Type to use for locating serializer to use, instead of actual * runtime type, if no serializer is passed * @param ser Root Serializer to use, if not null * * @since 2.1 */ public void serializeValue(JsonGenerator gen, Object value, JavaType rootType, JsonSerializer<Object> ser) throws IOException { if (value == null) { _serializeNull(gen); return; } // Let's ensure types are compatible at this point if ((rootType != null) && !rootType.getRawClass().isAssignableFrom(value.getClass())) { _reportIncompatibleRootType(value,

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> rootType); } // root value, not reached via property: if (ser == null) { ser = findTypedValueSerializer(rootType, true, null); } // Ok: should we wrap result in an additional property ("root name")? final boolean wrap; PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified // [JACKSON-163] wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = (rootType == null) ? _config.findRootName(value.getClass()) : _config.findRootName(rootType); gen.writeFieldName(pname.simpleAsEncoded(_config)); } } else if (rootName.isEmpty()) { wrap = false; } else { // [JACKSON-764] // empty String means explicitly disabled; non-empty that it is enabled wrap = true; gen.writeStartObject(); gen.writeFieldName(rootName.getSimpleName()); } try { ser.serialize(value, gen, this); if (wrap) { gen.writeEndObject(); } } catch (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw JsonMappingException.from(gen, msg, e); } } /** * Alternate serialization call used for polymorphic types, when {@link TypeSerializer} * is already known, but the actual serializer may or may not be. * * @since 2.6 */ public void serializePolymorphic(JsonGenerator gen, Object value, JavaType rootType, JsonSerializer<Object> valueSer, TypeSerializer typeSer) throws IOException { if (value == null) { _serializeNull(gen); return; } // Let's ensure types are compatible at this point if ((rootType != null) && !rootType.getRawClass().isAssignableFrom(value.getClass())) { _reportIncompatibleRootType(value, rootType); } /* 12-Jun-2015, tatu: nominal root type is necessary for Maps at least; * possibly collections, but can cause problems for other polymorphic * types. We really need to distinguish between serialization type, * base type; but right we don't. Hence this check */ if (valueSer == null) { if ((rootType != null) && rootType.isContainerType()) {

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>_EQUALITY_FOR_OBJECT_ID)) { return new HashMap<Object,WritableObjectId>(); } return new IdentityHashMap<Object,WritableObjectId>(); } /* /********************************************************** /* Factory method impls /********************************************************** */ @Override public JsonSerializer<Object> serializerInstance(Annotated annotated, Object serDef) throws JsonMappingException { if (serDef == null) { return null; } JsonSerializer<?> ser; if (serDef instanceof JsonSerializer) { ser = (JsonSerializer<?>) serDef; } else { /* Alas, there's no way to force return type of "either class * X or Y" -- need to throw an exception after the fact */ if (!(serDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned serializer definition of type " +serDef.getClass().getName()+"; expected type JsonSerializer or Class<JsonSerializer> instead"); } Class<?> serClass = (Class<?>)serDef; // there are some known "no class" markers to consider too: if (serClass == JsonSerializer.None.class || ClassUtil.isBogusClass(serClass)) { return null; } if (!JsonSerializer.class.isAssignableFrom(serClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +serClass.getName()+"; expected Class<JsonSerializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); ser = (hi == null) ? null : hi.serializerInstance(_config, annotated, serClass); if (ser == null) { ser = (JsonSerializer<?>) ClassUtil.createInstance(serClass, _config.canOverrideAccessModifiers()); } } return (JsonSerializer<Object>) _handleResolvable(ser); } /* /********************************************************** /* Helper classes /********************************************************** */ /** * Concrete implementation that defines factory method(s), * defined as final. */ public final static class Impl extends DefaultSerializerProvider { private static final long serialVersionUID = 1L; public Impl() { super(); } public Impl(Impl src) { super(src); } protected Impl(SerializerProvider src, SerializationConfig config,SerializerFactory f) { super(src, config, f); } @Override public DefaultSerializerProvider copy() { if (getClass() != Impl.class) { return super.copy(); } return new Impl(this); } @Override public Impl createInstance(SerializationConfig config, SerializerFactory jsf) { return new Impl(this, config, jsf); } } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>Type type, SerializationConfig config, BeanDescription beanDesc, boolean staticTyping) { Class<?> raw = type.getRawClass(); String clsName = raw.getName(); JsonSerializer<?> ser = _concrete.get(clsName); if (ser == null) { Class<? extends JsonSerializer<?>> serClass = _concreteLazy.get(clsName); if (serClass != null) { try { return serClass.newInstance(); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate standard serializer (of type "+serClass.getName()+"): " +e.getMessage(), e); } } } return ser; } /** * Method called to see if one of primary per-class annotations * (or related, like implementing of {@link JsonSerializable}) * determines the serializer to use. *<p> * Currently handles things like: *<ul> * <li>If type implements {@link JsonSerializable}, use that * </li> * <li>If type has {@link com.fasterxml.jackson.annotation.JsonValue} annotation (or equivalent), build serializer * based on that property * </li> *</ul> * * @since 2.0 */ protected final JsonSerializer<?> findSerializerByAnnotations(SerializerProvider prov, JavaType type, BeanDescription beanDesc) throws JsonMappingException { Class<?> raw = type.getRawClass(); // First: JsonSerializable? if (JsonSerializable.class.isAssignableFrom(raw)) { return SerializableSerializer.instance; } // Second: @JsonValue for any type AnnotatedMethod valueMethod = beanDesc.findJsonValueMethod(); if (valueMethod != null) { Method m = valueMethod.getAnnotated(); if (prov.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(m, prov.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } JsonSerializer<Object> ser = findSerializerFromAnnotation(prov, valueMethod); return new JsonValueSerializer(m, ser); } // No well-known annotations... return null; } /** * Method for checking if we can determine serializer to use based on set of * known primary types, checking for set of known base types (exact matches * having been compared against with <code>findSerializerByLookup</code>). * This does not include "secondary" interfaces, but * mostly concrete or abstract base classes. */ protected final JsonSerializer<?> findSerializerByPrimaryType(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { Class<?> raw = type.getRawClass(); // Then check for optional/external serializers JsonSerializer<?> ser = findOptionalStdSerializer(prov, type, beanDesc, staticTyping);

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> if (ser != null) { return ser; } if (Calendar.class.isAssignableFrom(raw)) { return CalendarSerializer.instance; } if (java.util.Date.class.isAssignableFrom(raw)) { return DateSerializer.instance; } if (Map.Entry.class.isAssignableFrom(raw)) { // 18-Oct-2015, tatu: With 2.7, need to dig type info: JavaType mapEntryType = type.findSuperType(Map.Entry.class); // 28-Apr-2015, tatu: TypeFactory does it all for us already so JavaType kt = mapEntryType.containedType(0); if (kt == null) { kt = TypeFactory.unknownType(); } JavaType vt = mapEntryType.containedType(1); if (vt == null) { vt = TypeFactory.unknownType(); } return buildMapEntrySerializer(prov.getConfig(), type, beanDesc, staticTyping, kt, vt); } if (ByteBuffer.class.isAssignableFrom(raw)) { return new ByteBufferSerializer(); } if (InetAddress.class.isAssignableFrom(raw)) { return new InetAddressSerializer(); } if (InetSocketAddress.class.isAssignableFrom(raw)) { return new InetSocketAddressSerializer(); } if (TimeZone.class.isAssignableFrom(raw)) { return new TimeZoneSerializer(); } if (java.nio.charset.Charset.class.isAssignableFrom(raw)) { return ToStringSerializer.instance; } if (Number.class.isAssignableFrom(raw)) { // 21-May-2014, tatu: Couple of alternatives actually JsonFormat.Value format = beanDesc.findExpectedFormat(null); if (format != null) { switch (format.getShape()) { case STRING: return ToStringSerializer.instance; case OBJECT: // need to bail out to let it be serialized as POJO case ARRAY: // or, I guess ARRAY; otherwise no point in speculating return null; default: } } return NumberSerializer.instance; } if (Enum.class.isAssignableFrom(raw)) { return buildEnumSerializer(prov.getConfig(), type, beanDesc); } return null; } /** * Overridable method called after checking all other types. * * @since 2.2 */ protected JsonSerializer<?> findOptionalStdSerializer(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { return OptionalHandlerFactory.instance.findSerializer(prov.getConfig(), type, beanDesc); } /** * Reflection-based serialized find method, which checks if * given class implements one of recognized "add-on" interfaces.

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> * Add-on here means a role that is usually or can be a secondary * trait: for example, * bean classes may implement {@link Iterable}, but their main * function is usually something else. The reason for */ protected final JsonSerializer<?> findSerializerByAddonType(SerializationConfig config, JavaType javaType, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { Class<?> rawType = javaType.getRawClass(); if (Iterator.class.isAssignableFrom(rawType)) { JavaType[] params = config.getTypeFactory().findTypeParameters(javaType, Iterator.class); JavaType vt = (params == null || params.length != 1) ? TypeFactory.unknownType() : params[0]; return buildIteratorSerializer(config, javaType, beanDesc, staticTyping, vt); } if (Iterable.class.isAssignableFrom(rawType)) { JavaType[] params = config.getTypeFactory().findTypeParameters(javaType, Iterable.class); JavaType vt = (params == null || params.length != 1) ? TypeFactory.unknownType() : params[0]; return buildIterableSerializer(config, javaType, beanDesc, staticTyping, vt); } if (CharSequence.class.isAssignableFrom(rawType)) { return ToStringSerializer.instance; } return null; } /** * Helper method called to check if a class or method * has an annotation * (@link com.fasterxml.jackson.databind.annotation.JsonSerialize#using) * that tells the class to use for serialization. * Returns null if no such annotation found. */ @SuppressWarnings("unchecked") protected JsonSerializer<Object> findSerializerFromAnnotation(SerializerProvider prov, Annotated a) throws JsonMappingException { Object serDef = prov.getAnnotationIntrospector().findSerializer(a); if (serDef == null) { return null; } JsonSerializer<Object> ser = prov.serializerInstance(a, serDef); // One more thing however: may need to also apply a converter: return (JsonSerializer<Object>) findConvertingSerializer(prov, a, ser); } /** * Helper method that will check whether given annotated entity (usually class, * but may also be a property accessor) indicates that a {@link Converter} is to * be used; and if so, to construct and return suitable serializer for it. * If not, will simply return given serializer as is. */ protected JsonSerializer<?> findConvertingSerializer(SerializerProvider prov, Annotated a, JsonSerializer<?> ser) throws JsonMappingException { Converter<Object,Object> conv = findConverter(prov, a); if (conv == null) { return ser; } JavaType delegateType = conv.getOutputType(prov.getTypeFactory()); return new Std

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>config, type, beanDesc, elementTypeSerializer, elementValueSerializer); if (ser != null) { break; } } if (ser == null) { ser = findSerializerByAnnotations(prov, type, beanDesc); // (2) Annotations if (ser == null) { // We may also want to use serialize Collections "as beans", if (and only if) // this is specified with `@JsonFormat(shape=Object)` JsonFormat.Value format = beanDesc.findExpectedFormat(null); if (format != null && format.getShape() == JsonFormat.Shape.OBJECT) { return null; } Class<?> raw = type.getRawClass(); if (EnumSet.class.isAssignableFrom(raw)) { // this may or may not be available (Class doesn't; type of field/method does) JavaType enumType = type.getContentType(); // and even if nominally there is something, only use if it really is enum if (!enumType.isEnumType()) { enumType = null; } ser = buildEnumSetSerializer(enumType); } else { Class<?> elementRaw = type.getContentType().getRawClass(); if (isIndexedList(raw)) { if (elementRaw == String.class) { // [JACKSON-829] Must NOT use if we have custom serializer if (elementValueSerializer == null || ClassUtil.isJacksonStdImpl(elementValueSerializer)) { ser = IndexedStringListSerializer.instance; } } else { ser = buildIndexedListSerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer); } } else if (elementRaw == String.class) { // [JACKSON-829] Must NOT use if we have custom serializer if (elementValueSerializer == null || ClassUtil.isJacksonStdImpl(elementValueSerializer)) { ser = StringCollectionSerializer.instance; } } if (ser == null) { ser = buildCollectionSerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer); } } } } // [databind#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifyCollectionSerializer(config, type, beanDesc, ser); } } return ser; } /* /********************************************************** /* Factory methods, for Collections /********************************************************** */ protected boolean isIndexedList(Class<?> cls) { return RandomAccess.class.isAssignableFrom(cls); } public ContainerSerializer<?> buildIndexedListSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, JsonSerializer<Object> value

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> annotated if (!explicit) { return; } // both explicit: verify verify = true; } else { // otherwise only verify if neither explicitly annotated. verify = !explicit; } // one more thing: ok to override in sub-class if (verify && (oldOne.getClass() == newOne.getClass())) { // [databind#667]: avoid one particular class of bogus problems Class<?> oldType = oldOne.getRawParameterType(0); Class<?> newType = newOne.getRawParameterType(0); if (oldType == newType) { throw new IllegalArgumentException("Conflicting "+TYPE_DESCS[typeIndex] +" creators: already had explicitly marked "+oldOne+", encountered "+newOne); } // otherwise, which one to choose? if (newType.isAssignableFrom(oldType)) { // new type more generic, use old return; } // new type more specific, use it } } if (explicit) { _explicitCreators |= mask; } _creators[typeIndex] = _fixAccess(newOne); } /* /********************************************************** /* Helper class(es) /********************************************************** */ protected final static class Vanilla extends ValueInstantiator implements java.io.Serializable { private static final long serialVersionUID = 1L; public final static int TYPE_COLLECTION = 1; public final static int TYPE_MAP = 2; public final static int TYPE_HASH_MAP = 3; private final int _type; public Vanilla(int t) { _type = t; } @Override public String getValueTypeDesc() { switch (_type) { case TYPE_COLLECTION: return ArrayList.class.getName(); case TYPE_MAP: return LinkedHashMap.class.getName(); case TYPE_HASH_MAP: return HashMap.class.getName(); } return Object.class.getName(); } @Override public boolean canInstantiate() { return true; } @Override public boolean canCreateUsingDefault() { return true; } @Override public Object createUsingDefault(DeserializationContext ctxt) throws IOException { switch (_type) { case TYPE_COLLECTION: return new ArrayList<Object>(); case TYPE_MAP: return new LinkedHashMap<String,Object>(); case TYPE_HASH_MAP: return new HashMap<String,Object>(); } throw new IllegalStateException("Unknown type "+_type); } } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>Type()) { return factory.createArrayDeserializer(ctxt, (ArrayType) type, beanDesc); } if (type.isMapLikeType()) { MapLikeType mlt = (MapLikeType) type; if (mlt.isTrueMapType()) { return factory.createMapDeserializer(ctxt,(MapType) mlt, beanDesc); } return factory.createMapLikeDeserializer(ctxt, mlt, beanDesc); } if (type.isCollectionLikeType()) { /* 03-Aug-2012, tatu: As per [Issue#40], one exception is if shape * is to be Shape.OBJECT. Ideally we'd determine it bit later on * (to allow custom handler checks), but that won't work for other * reasons. So do it here. */ JsonFormat.Value format = beanDesc.findExpectedFormat(null); if (format == null || format.getShape() != JsonFormat.Shape.OBJECT) { CollectionLikeType clt = (CollectionLikeType) type; if (clt.isTrueCollectionType()) { return factory.createCollectionDeserializer(ctxt, (CollectionType) clt, beanDesc); } return factory.createCollectionLikeDeserializer(ctxt, clt, beanDesc); } } } if (type.isReferenceType()) { return factory.createReferenceDeserializer(ctxt, (ReferenceType) type, beanDesc); } if (JsonNode.class.isAssignableFrom(type.getRawClass())) { return factory.createTreeDeserializer(config, type, beanDesc); } return factory.createBeanDeserializer(ctxt, type, beanDesc); } /** * Helper method called to check if a class or method * has annotation that tells which class to use for deserialization. * Returns null if no such annotation found. */ protected JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationContext ctxt, Annotated ann) throws JsonMappingException { Object deserDef = ctxt.getAnnotationIntrospector().findDeserializer(ann); if (deserDef == null) { return null; } JsonDeserializer<Object> deser = ctxt.deserializerInstance(ann, deserDef); // One more thing however: may need to also apply a converter: return findConvertingDeserializer(ctxt, ann, deser); } /** * Helper method that will check whether given annotated entity (usually class, * but may also be a property accessor) indicates that a {@link Converter} is to * be used; and if so, to construct and return suitable serializer for it. * If not, will simply return given serializer as is. */ protected JsonDeserializer<Object> findConvertingDeserializer(DeserializationContext ctxt, Annotated a, JsonDeserializer<Object> deser) throws JsonMappingException

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.ContainerSerializer; @JacksonStdImpl @SuppressWarnings("serial") public class IterableSerializer extends AsArraySerializerBase<Iterable<?>> { public IterableSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts) { super(Iterable.class, elemType, staticTyping, vts, null); } public IterableSerializer(IterableSerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSerializer, Boolean unwrapSingle) { super(src, property, vts, valueSerializer, unwrapSingle); } @Override public ContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts) { return new IterableSerializer(this, _property, vts, _elementSerializer, _unwrapSingle); } @Override public IterableSerializer withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle) { return new IterableSerializer(this, property, vts, elementSerializer, unwrapSingle); } @Override public boolean isEmpty(SerializerProvider prov, Iterable<?> value) { // Not really good way to implement this, but has to do for now: return (value == null) || !value.iterator().hasNext(); } @Override public boolean hasSingleElement(Iterable<?> value) { // we can do it actually (fixed in 2.3.1) if (value != null) { Iterator<?> it = value.iterator(); if (it.hasNext()) { it.next(); if (!it.hasNext()) { return true; } } } return false; } @Override public final void serialize(Iterable<?> value, JsonGenerator gen, SerializerProvider provider)throws IOException { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { if (hasSingleElement(value)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(); serializeContents(value, gen, provider); gen.writeEndArray(); } @Override public void serializeContents(Iterable<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException { Iterator<?> it = value.iterator(); if (it.hasNext()) { final TypeSerializer typeSer = _valueTypeSerializer; JsonSerializer<Object>

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> prevSerializer = null; Class<?> prevClass = null; do { Object elem = it.next(); if (elem == null) { provider.defaultSerializeNull(jgen); continue; } JsonSerializer<Object> currSerializer = _elementSerializer; if (currSerializer == null) { // Minor optimization to avoid most lookups: Class<?> cc = elem.getClass(); if (cc == prevClass) { currSerializer = prevSerializer; } else { currSerializer = provider.findValueSerializer(cc, _property); prevSerializer = currSerializer; prevClass = cc; } } if (typeSer == null) { currSerializer.serialize(elem, jgen, provider); } else { currSerializer.serializeWithType(elem, jgen, provider, typeSer); } } while (it.hasNext()); } } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> _typeHandler, true); } @Override public JavaType refine(Class<?> rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) { return new MapLikeType(rawType, bindings, superClass, superInterfaces, _keyType, _valueType, _valueHandler, _typeHandler, _asStatic); } @Override protected String buildCanonicalName() { StringBuilder sb = new StringBuilder(); sb.append(_class.getName()); if (_keyType != null) { sb.append('<'); sb.append(_keyType.toCanonical()); sb.append(','); sb.append(_valueType.toCanonical()); sb.append('>'); } return sb.toString(); } /* * /********************************************************** /* Public API * /********************************************************** */ @Override public boolean isContainerType() { return true; } @Override public boolean isMapLikeType() { return true; } @Override public JavaType getKeyType() { return _keyType; } @Override public JavaType getContentType() { return _valueType; } @Override public Object getContentValueHandler() { return _valueType.getValueHandler(); } @Override public Object getContentTypeHandler() { return _valueType.getTypeHandler(); } @Override public StringBuilder getErasedSignature(StringBuilder sb) { return _classSignature(_class, sb, true); } @Override public StringBuilder getGenericSignature(StringBuilder sb) { _classSignature(_class, sb, false); sb.append('<'); _keyType.getGenericSignature(sb); _valueType.getGenericSignature(sb); sb.append(">;"); return sb; } /* * /********************************************************** /* Extended * API /********************************************************** */ public MapLikeType withKeyTypeHandler(Object h) { return new MapLikeType(_class, _bindings, _superClass, _superInterfaces, _keyType.withTypeHandler(h), _valueType, _valueHandler, _typeHandler, _asStatic); } public MapLikeType withKeyValueHandler(Object h) { return new MapLikeType(_class, _bindings, _superClass, _superInterfaces, _keyType.withValueHandler(h), _valueType, _valueHandler, _typeHandler, _asStatic); } /** * Method that can be used for checking whether this type is a "real" * Collection type; meaning whether it represents a parameterized subtype of * {@link java.util.Collection} or just something that acts like one. */ public boolean isTrueMapType() { return Map.class.isAssignableFrom(_class); } /* * /********************************************************** /* Standard * methods /********************************************************** */ @Override public String toString()

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> Collections and Maps). * * @since 2.2 */ public abstract JavaType withStaticTyping(); /* /********************************************************** /* Type coercion fluent factory methods /********************************************************** */ /** * Mutant factory method that will try to create and return a sub-type instance * for known parameterized types; for other types will return `null` to indicate * that no just refinement makes necessary sense, without trying to detect * special status through implemented interfaces. * * @since 2.7 */ public abstract JavaType refine(Class<?> rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces); /** * Legacy method used for forcing sub-typing of this type into * type specified by specific type erasure. * Deprecated as of 2.7 as such specializations really ought to * go through {@link TypeFactory}, not directly via {@link JavaType}. * * @since 2.7 */ @Deprecated public JavaType forcedNarrowBy(Class<?> subclass) { if (subclass == _class) { // can still optimize for simple case return this; } JavaType result = _narrow(subclass); // TODO: these checks should NOT actually be needed; above should suffice: if (_valueHandler != result.<Object>getValueHandler()) { result = result.withValueHandler(_valueHandler); } if (_typeHandler != result.<Object>getTypeHandler()) { result = result.withTypeHandler(_typeHandler); } return result; } @Deprecated // since 2.7 protected abstract JavaType _narrow(Class<?> subclass); /* /********************************************************** /* Implementation of ResolvedType API /********************************************************** */ @Override public final Class<?> getRawClass() { return _class; } /** * Method that can be used to check whether this type has * specified Class as its type erasure. Put another way, returns * true if instantiation of this Type is given (type-erased) Class. */ @Override public final boolean hasRawClass(Class<?> clz) { return _class == clz; } /** * @since 2.6 */ public final boolean isTypeOrSubTypeOf(Class<?> clz) { return (_class == clz) || (clz.isAssignableFrom(_class)); } @Override public boolean isAbstract() { return Modifier.isAbstract(_class.getModifiers()); } /** * Convenience method for checking whether underlying Java type * is a concrete class or not: abstract classes and interfaces * are not. */ @Override public boolean isConcrete() { int mod = _class.getModifiers(); if ((mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0) {

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> return true; } /* 19-Feb-2010, tatus: Holy mackarel; primitive types * have 'abstract' flag set... */ return _class.isPrimitive(); } @Override public boolean isThrowable() { return Throwable.class.isAssignableFrom(_class); } @Override public boolean isArrayType() { return false; } @Override public final boolean isEnumType() { return _class.isEnum(); } @Override public final boolean isInterface() { return _class.isInterface(); } @Override public final boolean isPrimitive() { return _class.isPrimitive(); } @Override public final boolean isFinal() { return Modifier.isFinal(_class.getModifiers()); } /** * @return True if type represented is a container type; this includes * array, Map and Collection types. */ @Override public abstract boolean isContainerType(); /** * @return True if type is either true {@link java.util.Collection} type, * or something similar (meaning it has at least one type parameter, * which describes type of contents) */ @Override public boolean isCollectionLikeType() { return false; } /** * @return True if type is either true {@link java.util.Map} type, * or something similar (meaning it has at least two type parameter; * first one describing key type, second value type) */ @Override public boolean isMapLikeType() { return false; } /** * Convenience method, short-hand for *<code> * getRawClass() == Object.class *</code> * and used to figure if we basically have "untyped" type object. * * @since 2.5 */ public final boolean isJavaLangObject() { return _class == Object.class; } /** * Accessor for checking whether handlers for dealing with values of * this type should use static typing (as opposed to dynamic typing). * Note that while value of 'true' does mean that static typing is to * be used, value of 'false' may still be overridden by other settings. * * @since 2.2 */ public final boolean useStaticType() { return _asStatic; } /* /********************************************************** /* Public API, type parameter access; pass-through /********************************************************** */ @Override public boolean hasGenericTypes() { return containedTypeCount() > 0; } @Override public JavaType getKeyType() { return null; } @Override public JavaType getContentType() { return null; } @Override // since 2.6 public JavaType getReferencedType() { return null; } @Override public abstract int containedTypeCount(); @Override

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> public abstract JavaType containedType(int index); @Deprecated // since 2.7 @Override public abstract String containedTypeName(int index); @Deprecated // since 2.7 @Override public Class<?> getParameterSource() { return null; } /* /********************************************************** /* Extended API beyond ResolvedType /********************************************************** */ // NOTE: not defined in Resolved type /** * Convenience method that is functionally same as: *<code> * JavaType t = containedType(index); * if (t == null) { * t = TypeFactory.unknownType(); * } *</code> * and typically used to eliminate need for null checks for common case * where we just want to check if containedType is available first; and * if not, use "unknown type" (which translates to <code>java.lang.Object</code> * basically). * * @since 2.5 */ public JavaType containedTypeOrUnknown(int index) { JavaType t = containedType(index); return (t == null) ? TypeFactory.unknownType() : t; } /** * @since 2.7 */ public abstract TypeBindings getBindings(); /** * Method that may be called to find representation of given type * within type hierarchy of this type: either this type (if this * type has given erased type), one of its supertypes that has the * erased types, or null if target is neither this type or any of its * supertypes. * * @since 2.7 */ public abstract JavaType findSuperType(Class<?> erasedTarget); /** * Accessor for finding fully resolved parent class of this type, * if it has one; null if not. * * @since 2.7 */ public abstract JavaType getSuperClass(); /** * Accessor for finding fully resolved interfaces this type implements, * if any; empty array if none. * * @since 2.7 */ public abstract List<JavaType> getInterfaces(); /** * Method that may be used to find paramaterization this type has for * given type-erased generic target type. * * @since 2.7 */ public abstract JavaType[] findTypeParameters(Class<?> expType); /* /********************************************************** /* Semi-public API, accessing handlers /********************************************************** */ /** * Method for accessing value handler associated with this type, if any */ @SuppressWarnings("unchecked") public <T> T getValueHandler() { return (T) _valueHandler; } /** * Method for accessing type handler associated with this type, if any */ @SuppressWarnings("unchecked") public <T> T getTypeHandler()

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>, config.canOverrideAccessModifiers()); } return resolver; } /** * Helper method to use to construct a {@link Converter}, given a definition * that may be either actual converter instance, or Class for instantiating one. * * @since 2.2 */ @SuppressWarnings("unchecked") public Converter<Object,Object> converterInstance(Annotated annotated, Object converterDef) throws JsonMappingException { if (converterDef == null) { return null; } if (converterDef instanceof Converter<?,?>) { return (Converter<Object,Object>) converterDef; } if (!(converterDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned Converter definition of type " +converterDef.getClass().getName()+"; expected type Converter or Class<Converter> instead"); } Class<?> converterClass = (Class<?>)converterDef; // there are some known "no class" markers to consider too: if (converterClass == Converter.None.class || ClassUtil.isBogusClass(converterClass)) { return null; } if (!Converter.class.isAssignableFrom(converterClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +converterClass.getName()+"; expected Class<Converter>"); } final MapperConfig<?> config = getConfig(); HandlerInstantiator hi = config.getHandlerInstantiator(); Converter<?,?> conv = (hi == null) ? null : hi.converterInstance(config, annotated, converterClass); if (conv == null) { conv = (Converter<?,?>) ClassUtil.createInstance(converterClass, config.canOverrideAccessModifiers()); } return (Converter<Object,Object>) conv; } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.jsontype.impl; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.BeanDescription; import com.fasterxml.jackson.databind.DatabindContext; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.jsontype.NamedType; import java.util.Collection; import java.util.HashMap; import java.util.TreeSet; public class TypeNameIdResolver extends TypeIdResolverBase { protected final MapperConfig<?> _config; /** * Mappings from class name to type id, used for serialization */ protected final HashMap<String, String> _typeToId; /** * Mappings from type id to JavaType, used for deserialization */ protected final HashMap<String, JavaType> _idToType; protected TypeNameIdResolver(MapperConfig<?> config, JavaType baseType, HashMap<String, String> typeToId, HashMap<String, JavaType> idToType) { super(baseType, config.getTypeFactory()); _config = config; _typeToId = typeToId; _idToType = idToType; } public static TypeNameIdResolver construct(MapperConfig<?> config, JavaType baseType, Collection<NamedType> subtypes, boolean forSer, boolean forDeser) { // sanity check if (forSer == forDeser) throw new IllegalArgumentException(); HashMap<String, String> typeToId = null; HashMap<String, JavaType> idToType = null; if (forSer) { typeToId = new HashMap<String, String>(); } if (forDeser) { idToType = new HashMap<String, JavaType>(); } if (subtypes != null) { for (NamedType t : subtypes) { /* no name? Need to figure out default; for now, let's just * use non-qualified class name */ Class<?> cls = t.getType(); String id = t.hasName() ? t.getName() : _defaultTypeId(cls); if (forSer) { typeToId.put(cls.getName(), id); } if (forDeser) { /* 24-Feb-2011, tatu: [JACKSON-498] One more problem; sometimes * we have same name for multiple types; if so, use most specific * one. */ JavaType prev = idToType.get(id); if (prev != null) { // Can only override if more specific if (cls.isAssignableFrom(prev.getRawClass())) { //

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> and its subtypes. */ NON_CONCRETE_AND_ARRAYS, /** * Value that means that default typing will be used for * all non-final types, with exception of small number of * "natural" types (String, Boolean, Integer, Double), which * can be correctly inferred from JSON; as well as for * all arrays of non-final types. *<p> * Since 2.4, this does NOT apply to {@link TreeNode} and its subtypes. */ NON_FINAL } /** * Customized {@link TypeResolverBuilder} that provides type resolver builders * used with so-called "default typing" * (see {@link ObjectMapper#enableDefaultTyping()} for details). *<p> * Type resolver construction is based on configuration: implementation takes care * of only providing builders in cases where type information should be applied. * This is important since build calls may be sent for any and all types, and * type information should NOT be applied to all of them. */ public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder implements java.io.Serializable { private static final long serialVersionUID = 1L; /** * Definition of what types is this default typer valid for. */ protected final DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(DefaultTyping t) { _appliesFor = t; } @Override public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes) { return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes) : null; } @Override public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) { return useForType(baseType) ? super.buildTypeSerializer(config, baseType, subtypes) : null; } /** * Method called to check if the default type handler should be * used for given type. * Note: "natural types" (String, Boolean, Integer, Double) will never * use typing; that is both due to them being concrete and final, * and since actual serializers and deserializers will also ignore any * attempts to enforce typing. */ public boolean useForType(JavaType t) { switch (_appliesFor) { case NON_CONCRETE_AND_ARRAYS: while (t.isArrayType()) { t = t.getContentType(); } // fall through case OBJECT_AND_NON_CONCRETE: return t.isJavaLangObject() || (!t.isConcrete() // [databind#88] Should not apply to JSON tree models: && !TreeNode.class.isAssignableFrom(t.

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>getRawClass())); case NON_FINAL: while (t.isArrayType()) { t = t.getContentType(); } // [Issue#88] Should not apply to JSON tree models: return !t.isFinal() && !TreeNode.class.isAssignableFrom(t.getRawClass()); default: //case JAVA_LANG_OBJECT: return t.isJavaLangObject(); } } } /* /********************************************************** /* Internal constants, singletons /********************************************************** */ // Quick little shortcut, to avoid having to use global TypeFactory instance... // 19-Oct-2015, tatu: Not sure if this is really safe to do; let's at least allow // some amount of introspection private final static JavaType JSON_NODE_TYPE = SimpleType.constructUnsafe(JsonNode.class); // TypeFactory.defaultInstance().constructType(JsonNode.class); // 16-May-2009, tatu: Ditto ^^^ protected final static AnnotationIntrospector DEFAULT_ANNOTATION_INTROSPECTOR = new JacksonAnnotationIntrospector(); protected final static VisibilityChecker<?> STD_VISIBILITY_CHECKER = VisibilityChecker.Std.defaultInstance(); /** * @deprecated Since 2.6, do not use: will be removed in 2.7 or later */ @Deprecated protected final static PrettyPrinter _defaultPrettyPrinter = new DefaultPrettyPrinter(); /** * Base settings contain defaults used for all {@link ObjectMapper} * instances. */ protected final static BaseSettings DEFAULT_BASE = new BaseSettings( null, // can not share global ClassIntrospector any more (2.5+) DEFAULT_ANNOTATION_INTROSPECTOR, STD_VISIBILITY_CHECKER, null, TypeFactory.defaultInstance(), null, StdDateFormat.instance, null, Locale.getDefault(), null, // to indicate "use default TimeZone" Base64Variants.getDefaultVariant() // 2.1 ); /* /********************************************************** /* Configuration settings, shared /********************************************************** */ /** * Factory used to create {@link JsonParser} and {@link JsonGenerator} * instances as necessary. */ protected final JsonFactory _jsonFactory; /** * Specific factory used for creating {@link JavaType} instances; * needed to allow modules to add more custom type handling * (mostly to support types of non-Java JVM languages) */ protected TypeFactory _typeFactory; /** * Provider for values to inject in deserialized POJOs. */ protected InjectableValues _injectableValues; /** * Thing used for registering sub-types, resolving them to * super/sub-types as needed. */ protected SubtypeResolver _subtypeResolver; /* /********************************************************** /* Configuration settings

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> */ public void writeTree(JsonGenerator jgen, JsonNode rootNode) throws IOException, JsonProcessingException { SerializationConfig config = getSerializationConfig(); _serializerProvider(config).serializeValue(jgen, rootNode); if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { jgen.flush(); } } /** *<p> * Note: return type is co-variant, as basic ObjectCodec * abstraction can not refer to concrete node types (as it's * part of core package, whereas impls are part of mapper * package) */ @Override public ObjectNode createObjectNode() { return _deserializationConfig.getNodeFactory().objectNode(); } /** *<p> * Note: return type is co-variant, as basic ObjectCodec * abstraction can not refer to concrete node types (as it's * part of core package, whereas impls are part of mapper * package) */ @Override public ArrayNode createArrayNode() { return _deserializationConfig.getNodeFactory().arrayNode(); } /** * Method for constructing a {@link JsonParser} out of JSON tree * representation. * * @param n Root node of the tree that resulting parser will read from */ @Override public JsonParser treeAsTokens(TreeNode n) { return new TreeTraversingParser((JsonNode) n, this); } /** * Convenience conversion method that will bind data given JSON tree * contains into specific value (usually bean) type. *<p> * Functionally equivalent to: *<pre> * objectMapper.convertValue(n, valueClass); *</pre> */ @SuppressWarnings("unchecked") @Override public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { // [Issue-11]: Simple cast when we just want to cast to, say, ObjectNode // ... one caveat; while everything is Object.class, let's not take shortcut if (valueType != Object.class && valueType.isAssignableFrom(n.getClass())) { return (T) n; } return readValue(treeAsTokens(n), valueType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } } /** * Reverse of {@link #treeToValue}; given a value (usually bean), will * construct equivalent JSON Tree representation. Functionally similar * to serializing value into JSON and parsing JSON as tree, but * more efficient. *<p> * NOTE: while results are usually identical to that of serialization followed * by de

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>wrapping is actually desired, * caller must use explicit <code>writeValue</code> and * <code>readValue</code> methods. */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [databind#11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { buf = buf.forceUseOfBigDecimal(true); } try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().without(SerializationFeature.WRAP_ROOT_VALUE); // no need to check for closing of TokenBuffer _serializerProvider(config).serializeValue(buf, fromValue); // then matching read, inlined 'readValue' with minor mods: final JsonParser jp = buf.asParser(); Object result; // ok to pass in existing feature flags; unwrapping handled by mapper final DeserializationConfig deserConfig = getDeserializationConfig(); JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL) { DeserializationContext ctxt = createDeserializationContext(jp, deserConfig); result = _findRootDeserializer(ctxt, toValueType).getNullValue(ctxt); } else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = null; } else { // pointing to event other than null DeserializationContext ctxt = createDeserializationContext(jp, deserConfig); JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, toValueType); // note: no handling of unwarpping result = deser.deserialize(jp, ctxt); } jp.close(); return result; } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } } /* /********************************************************** /* Extended Public API: JSON Schema generation /********************************************************** */ /** * Generate <a href="http://json-schema.org/">Json-schema</a> * instance for specified class. * * @param t The class to generate schema for * @

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>Util: can be overridden with custom handling return getTypeFactory().findClass(className); } /* /********************************************************** /* Public API, helper object recycling /********************************************************** */ /** * Method that can be used to get access to a reusable ObjectBuffer, * useful for efficiently constructing Object arrays and Lists. * Note that leased buffers should be returned once deserializer * is done, to allow for reuse during same round of deserialization. */ public final ObjectBuffer leaseObjectBuffer() { ObjectBuffer buf = _objectBuffer; if (buf == null) { buf = new ObjectBuffer(); } else { _objectBuffer = null; } return buf; } /** * Method to call to return object buffer previously leased with * {@link #leaseObjectBuffer}. * * @param buf Returned object buffer */ public final void returnObjectBuffer(ObjectBuffer buf) { /* Already have a reusable buffer? Let's retain bigger one * (or if equal, favor newer one, shorter life-cycle) */ if (_objectBuffer == null || buf.initialCapacity() >= _objectBuffer.initialCapacity()) { _objectBuffer = buf; } } /** * Method for accessing object useful for building arrays of * primitive types (such as int[]). */ public final ArrayBuilders getArrayBuilders() { if (_arrayBuilders == null) { _arrayBuilders = new ArrayBuilders(); } return _arrayBuilders; } /* /********************************************************** /* Extended API: handler instantiation /********************************************************** */ public abstract JsonDeserializer<Object> deserializerInstance(Annotated annotated, Object deserDef) throws JsonMappingException; public abstract KeyDeserializer keyDeserializerInstance(Annotated annotated, Object deserDef) throws JsonMappingException; /* /********************************************************** /* Extended API: resolving contextual deserializers; called /* by structured deserializers for their value/component /* deserializers /********************************************************** */ /** * Method called for primary property deserializers (ones * directly created to deserialize values of a POJO property), * to handle details of resolving * {@link ContextualDeserializer} with given property context. * * @param prop Property for which the given primary deserializer is used; never null. * * @since 2.5 */ public JsonDeserializer<?> handlePrimaryContextualization(JsonDeserializer<?> deser, BeanProperty prop, JavaType type) throws JsonMappingException { if (deser instanceof ContextualDeserializer) { _currentType = new LinkedNode<JavaType>(type, _currentType); try { deser = ((ContextualDeserializer) deser).createContextual(this, prop); } finally { _currentType = _currentType.next(); } } return

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> deser; } /** * Method called for secondary property deserializers (ones * NOT directly created to deal with an annotatable POJO property, * but instead created as a component -- such as value deserializers * for structured types, or deserializers for root values) * to handle details of resolving * {@link ContextualDeserializer} with given property context. * Given that these deserializers are not directly related to given property * (or, in case of root value property, to any property), annotations * accessible may or may not be relevant. * * @param prop Property for which deserializer is used, if any; null * when deserializing root values * * @since 2.5 */ public JsonDeserializer<?> handleSecondaryContextualization(JsonDeserializer<?> deser, BeanProperty prop, JavaType type) throws JsonMappingException { if (deser instanceof ContextualDeserializer) { _currentType = new LinkedNode<JavaType>(type, _currentType); try { deser = ((ContextualDeserializer) deser).createContextual(this, prop); } finally { _currentType = _currentType.next(); } } return deser; } @Deprecated // since 2.5; remove from 2.7 public JsonDeserializer<?> handlePrimaryContextualization(JsonDeserializer<?> deser, BeanProperty prop) throws JsonMappingException { return handlePrimaryContextualization(deser, prop, TypeFactory.unknownType()); } @Deprecated // since 2.5; remove from 2.7 public JsonDeserializer<?> handleSecondaryContextualization(JsonDeserializer<?> deser, BeanProperty prop) throws JsonMappingException { if (deser instanceof ContextualDeserializer) { deser = ((ContextualDeserializer) deser).createContextual(this, prop); } return deser; } /* /********************************************************** /* Parsing methods that may use reusable/-cyclable objects /********************************************************** */ /** * Convenience method for parsing a Date from given String, using * currently configured date format (accessed using * {@link DeserializationConfig#getDateFormat()}). *<p> * Implementation will handle thread-safety issues related to * date formats such that first time this method is called, * date format is cloned, and cloned instance will be retained * for use during this deserialization round. */ public Date parseDate(String dateStr) throws IllegalArgumentException { try { DateFormat df = getDateFormat(); return df.parse(dateStr); } catch (ParseException e) { throw new IllegalArgumentException(String.format( "Failed to parse Date value '%s': %s", dateStr, e.getMessage())); } } /** * Convenience method for constructing Calendar instance set * to specified time, to be modified and used by caller. */ public

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> an unrecognized property. * * @return True if there was a configured problem handler that was able to handle the * problem */ /** * Method deserializers can call to inform configured {@link DeserializationProblemHandler}s * of an unrecognized property. */ public boolean handleUnknownProperty(JsonParser p, JsonDeserializer<?> deser, Object instanceOrClass, String propName) throws IOException, JsonProcessingException { LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); if (h != null) { while (h != null) { // Can bail out if it's handled if (h.value().handleUnknownProperty(this, p, deser, instanceOrClass, propName)) { return true; } h = h.next(); } } return false; } /** * Helper method for reporting a problem with unhandled unknown exception * * @param instanceOrClass Either value being populated (if one has been * instantiated), or Class that indicates type that would be (or * have been) instantiated * @param deser Deserializer that had the problem, if called by deserializer * (or on behalf of one) */ public void reportUnknownProperty(Object instanceOrClass, String fieldName, JsonDeserializer<?> deser) throws JsonMappingException { if (!isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) { return; } // Do we know properties that are expected instead? Collection<Object> propIds = (deser == null) ? null : deser.getKnownPropertyNames(); throw UnrecognizedPropertyException.from(_parser, instanceOrClass, fieldName, propIds); } /* /********************************************************** /* Methods for constructing exceptions /********************************************************** */ /** * Helper method for constructing generic mapping exception for specified type */ public JsonMappingException mappingException(Class<?> targetClass) { return mappingException(targetClass, _parser.getCurrentToken()); } public JsonMappingException mappingException(Class<?> targetClass, JsonToken token) { return JsonMappingException.from(_parser, String.format("Can not deserialize instance of %s out of %s token", _calcName(targetClass), token)); } /** * Helper method for constructing generic mapping exception with specified * message and current location information */ public JsonMappingException mappingException(String message) { return JsonMappingException.from(getParser(), message); } /** * Helper method for constructing generic mapping exception with specified * message and current location information * * @since 2.6 */ public JsonMappingException mappingException(String msgTemplate, Object... args) { String message = String.format(msgTemplate, args); return JsonMappingException.from(getParser(), message); }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> // only add if we can access... but otherwise? if (fixAccess) { accessor.fixAccess(forceAccess); } builder.setTypeId(accessor); } continue; } // suppress writing of back references AnnotationIntrospector.ReferenceProperty refType = property.findReferenceType(); if (refType != null && refType.isBackReference()) { continue; } if (accessor instanceof AnnotatedMethod) { result.add(_constructWriter(prov, property, pb, staticTyping, (AnnotatedMethod) accessor)); } else { result.add(_constructWriter(prov, property, pb, staticTyping, (AnnotatedField) accessor)); } } return result; } /* /********************************************************** /* Overridable non-public methods for manipulating bean properties /********************************************************** */ /** * Overridable method that can filter out properties. Default implementation * checks annotations class may have. */ protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyWriter> props) { AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); String[] ignored = intr.findPropertiesToIgnore(ac, true); if (ignored != null && ignored.length > 0) { HashSet<String> ignoredSet = ArrayBuilders.arrayToSet(ignored); Iterator<BeanPropertyWriter> it = props.iterator(); while (it.hasNext()) { if (ignoredSet.contains(it.next().getName())) { it.remove(); } } } return props; } /** * Method called to handle view information for constructed serializer, * based on bean property writers. *<p> * Note that this method is designed to be overridden by sub-classes * if they want to provide custom view handling. As such it is not * considered an internal implementation detail, and will be supported * as part of API going forward. */ protected void processViews(SerializationConfig config, BeanSerializerBuilder builder) { // [JACKSON-232]: whether non-annotated fields are included by default or not is configurable List<BeanPropertyWriter> props = builder.getProperties(); boolean includeByDefault = config.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION); final int propCount = props.size(); int viewsFound = 0; BeanPropertyWriter[] filtered = new BeanPropertyWriter[propCount]; // Simple: view information is stored within individual writers, need to combine: for (int i = 0; i < propCount; ++i) { BeanPropertyWriter bpw = props.get(i); Class<?>[] views = bpw.getViews(); if (views == null)

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> { // no view info? include or exclude by default? if (includeByDefault) { filtered[i] = bpw; } } else { ++viewsFound; filtered[i] = constructFilteredBeanWriter(bpw, views); } } // minor optimization: if no view info, include-by-default, can leave out filtering info altogether: if (includeByDefault && viewsFound == 0) { return; } builder.setFilteredProperties(filtered); } /** * Method that will apply by-type limitations (as per [JACKSON-429]); * by default this is based on {@link com.fasterxml.jackson.annotation.JsonIgnoreType} * annotation but can be supplied by module-provided introspectors too. */ protected void removeIgnorableTypes(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyDefinition> properties) { AnnotationIntrospector intr = config.getAnnotationIntrospector(); HashMap<Class<?>,Boolean> ignores = new HashMap<Class<?>,Boolean>(); Iterator<BeanPropertyDefinition> it = properties.iterator(); while (it.hasNext()) { BeanPropertyDefinition property = it.next(); AnnotatedMember accessor = property.getAccessor(); if (accessor == null) { it.remove(); continue; } Class<?> type = accessor.getRawType(); Boolean result = ignores.get(type); if (result == null) { BeanDescription desc = config.introspectClassAnnotations(type); AnnotatedClass ac = desc.getClassInfo(); result = intr.isIgnorableType(ac); // default to false, non-ignorable if (result == null) { result = Boolean.FALSE; } ignores.put(type, result); } // lotsa work, and yes, it is ignorable type, so: if (result.booleanValue()) { it.remove(); } } } /** * Helper method that will remove all properties that do not have a mutator. */ protected void removeSetterlessGetters(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyDefinition> properties) { Iterator<BeanPropertyDefinition> it = properties.iterator(); while (it.hasNext()) { BeanPropertyDefinition property = it.next(); // one caveat: as per [JACKSON-806], only remove implicit properties; // explicitly annotated ones should remain if (!property.couldDeserialize() && !property.isExplicitlyIncluded()) { it.remove(); } } } /** * Helper method called to ensure that we do not have "duplicate" type ids. * Added to resolve [databind#222] * * @since 2.6 */ protected List<BeanPropertyWriter>

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>) { _addMethodMixIns(_class, _memberMethods, mixin, mixins); } } /* Any unmatched mix-ins? Most likely error cases (not matching * any method); but there is one possible real use case: * exposing Object#hashCode (alas, Object#getClass can NOT be * exposed, see [JACKSON-140]) */ // 14-Feb-2011, tatu: AnnotationIntrospector is null if annotations not enabled; if so, can skip: if (_annotationIntrospector != null) { if (!mixins.isEmpty()) { Iterator<AnnotatedMethod> it = mixins.iterator(); while (it.hasNext()) { AnnotatedMethod mixIn = it.next(); try { Method m = Object.class.getDeclaredMethod(mixIn.getName(), mixIn.getRawParameterTypes()); if (m != null) { // Since it's from java.lang.Object, no generics, no need for real type context: AnnotatedMethod am = _constructMethod(m, this); _addMixOvers(mixIn.getAnnotated(), am, false); _memberMethods.add(am); } } catch (Exception e) { } } } } } /** * Method that will collect all member (non-static) fields * that are either public, or have at least a single annotation * associated with them. */ private void resolveFields() { Map<String,AnnotatedField> foundFields = _findFields(_type, this, null); if (foundFields == null || foundFields.size() == 0) { _fields = Collections.emptyList(); } else { _fields = new ArrayList<AnnotatedField>(foundFields.size()); _fields.addAll(foundFields.values()); } } /* /********************************************************** /* Helper methods for resolving class annotations /* (resolution consisting of inheritance, overrides, /* and injection of mix-ins as necessary) /********************************************************** */ /** * Helper method for adding any mix-in annotations specified * class might have. */ protected void _addClassMixIns(AnnotationMap annotations, JavaType target) { if (_mixInResolver != null) { final Class<?> toMask = target.getRawClass(); _addClassMixIns(annotations, toMask, _mixInResolver.findMixInClassFor(toMask)); } } protected void _addClassMixIns(AnnotationMap annotations, Class<?> target) { if (_mixInResolver != null) { _addClassMixIns(annotations, target, _mixInResolver.findMixInClassFor(target)); } } protected void _addClassMixIns(AnnotationMap annotations, Class<?> toMask, Class<?> mixin) { if (mixin

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>Override public boolean hasConstructorParameter() { return _ctorParameters != null; } @Override public boolean couldDeserialize() { return (_ctorParameters != null) || (_setters != null) || (_fields != null); } @Override public boolean couldSerialize() { return (_getters != null) || (_fields != null); } @Override public AnnotatedMethod getGetter() { // Easy with zero or one getters... Linked<AnnotatedMethod> curr = _getters; if (curr == null) { return null; } Linked<AnnotatedMethod> next = curr.next; if (next == null) { return curr.value; } // But if multiple, verify that they do not conflict... for (; next != null; next = next.next) { /* [JACKSON-255] Allow masking, i.e. do not report exception if one * is in super-class from the other */ Class<?> currClass = curr.value.getDeclaringClass(); Class<?> nextClass = next.value.getDeclaringClass(); if (currClass != nextClass) { if (currClass.isAssignableFrom(nextClass)) { // next is more specific curr = next; continue; } if (nextClass.isAssignableFrom(currClass)) { // current more specific continue; } } /* 30-May-2014, tatu: Three levels of precedence: * * 1. Regular getters ("getX") * 2. Is-getters ("isX") * 3. Implicit, possible getters ("x") */ int priNext = _getterPriority(next.value); int priCurr = _getterPriority(curr.value); if (priNext != priCurr) { if (priNext < priCurr) { curr = next; } continue; } throw new IllegalArgumentException("Conflicting getter definitions for property \""+getName()+"\": " +curr.value.getFullName()+" vs "+next.value.getFullName()); } // One more thing; to avoid having to do it again... _getters = curr.withoutNext(); return curr.value; } @Override public AnnotatedMethod getSetter() { // Easy with zero or one getters... Linked<AnnotatedMethod> curr = _setters; if (curr == null) { return null; } Linked<AnnotatedMethod> next = curr.next; if (next == null) { return curr.value; } // But if multiple, verify that they do not conflict... for (; next != null; next = next.next) { // Allow masking, i.e. do not fail if one is in super-class from the other Class<?> currClass

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> = curr.value.getDeclaringClass(); Class<?> nextClass = next.value.getDeclaringClass(); if (currClass != nextClass) { if (currClass.isAssignableFrom(nextClass)) { // next is more specific curr = next; continue; } if (nextClass.isAssignableFrom(currClass)) { // current more specific continue; } } AnnotatedMethod nextM = next.value; AnnotatedMethod currM = curr.value; /* 30-May-2014, tatu: Two levels of precedence: * * 1. Regular setters ("setX(...)") * 2. Implicit, possible setters ("x(...)") */ int priNext = _setterPriority(nextM); int priCurr = _setterPriority(currM); if (priNext != priCurr) { if (priNext < priCurr) { curr = next; } continue; } // 11-Dec-2015, tatu: As per [databind#1033] allow pluggable conflict resolution if (_annotationIntrospector != null) { AnnotatedMethod pref = _annotationIntrospector.resolveSetterConflict(_config, currM, nextM); // note: should be one of nextM/currM; but no need to check if (pref == currM) { continue; } if (pref == nextM) { curr = next; continue; } } throw new IllegalArgumentException("Conflicting setter definitions for property \""+getName()+"\": " +curr.value.getFullName()+" vs "+next.value.getFullName()); } // One more thing; to avoid having to do it again... _setters = curr.withoutNext(); return curr.value; } @Override public AnnotatedField getField() { if (_fields == null) { return null; } // If multiple, verify that they do not conflict... AnnotatedField field = _fields.value; Linked<AnnotatedField> next = _fields.next; for (; next != null; next = next.next) { AnnotatedField nextField = next.value; Class<?> fieldClass = field.getDeclaringClass(); Class<?> nextClass = nextField.getDeclaringClass(); if (fieldClass != nextClass) { if (fieldClass.isAssignableFrom(nextClass)) { // next is more specific field = nextField; continue; } if (nextClass.isAssignableFrom(fieldClass)) { // getter more specific continue; } } throw new IllegalArgumentException("Multiple fields representing property \""+getName()+"\": " +field.getFullName()+" vs "+nextField.getFullName()); } return field; } @Override public Annot

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>atedParameter getConstructorParameter() { if (_ctorParameters == null) { return null; } /* Hmmh. Checking for constructor parameters is trickier; for one, * we must allow creator and factory method annotations. * If this is the case, constructor parameter has the precedence. * * So, for now, just try finding the first constructor parameter; * if none, first factory method. And don't check for dups, if we must, * can start checking for them later on. */ Linked<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; } @Override public Iterator<AnnotatedParameter> getConstructorParameters() { if (_ctorParameters == null) { return ClassUtil.emptyIterator(); } return new MemberIterator<AnnotatedParameter>(_ctorParameters); } @Override public AnnotatedMember getAccessor() { AnnotatedMember m = getGetter(); if (m == null) { m = getField(); } return m; } @Override public AnnotatedMember getMutator() { AnnotatedMember m = getConstructorParameter(); if (m == null) { m = getSetter(); if (m == null) { m = getField(); } } return m; } @Override public AnnotatedMember getNonConstructorMutator() { AnnotatedMember m = getSetter(); if (m == null) { m = getField(); } return m; } @Override public AnnotatedMember getPrimaryMember() { if (_forSerialization) { return getAccessor(); } return getMutator(); } protected int _getterPriority(AnnotatedMethod m) { final String name = m.getName(); // [databind#238]: Also, regular getters have precedence over "is-getters" if (name.startsWith("get") && name.length() > 3) { // should we check capitalization? return 1; } if (name.startsWith("is") && name.length() > 2) { return 2; } return 3; } protected int _setterPriority(AnnotatedMethod m) { final String name = m.getName(); if (name.startsWith("set") && name.length() > 3) { // should we check capitalization? return 1; } return 2; } /* /********************************************************** /* Implementations of refinement accessors /********************************************************** */ @Override public Class<?>[] findViews() { return fromMemberAnnotations(new With

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> } else { // for deserialization if (_ctorParameters != null) { AnnotationMap ann = _mergeAnnotations(0, _ctorParameters, _setters, _fields, _getters); _ctorParameters = _applyAnnotations(_ctorParameters, ann); } else if (_setters != null) { AnnotationMap ann = _mergeAnnotations(0, _setters, _fields, _getters); _setters = _applyAnnotations(_setters, ann); } else if (_fields != null) { AnnotationMap ann = _mergeAnnotations(0, _fields, _getters); _fields = _applyAnnotations(_fields, ann); } } } private AnnotationMap _mergeAnnotations(int index, Linked<? extends AnnotatedMember>... nodes) { AnnotationMap ann = _getAllAnnotations(nodes[index]); while (++index < nodes.length) { if (nodes[index] != null) { return AnnotationMap.merge(ann, _mergeAnnotations(index, nodes)); } } return ann; } /** * Replacement, as per [databind#868], of simple access to annotations, which * does "deep merge" if an as necessary. *<pre> * nodes[index].value.getAllAnnotations() *</pre> * * @since 2.6 */ private <T extends AnnotatedMember> AnnotationMap _getAllAnnotations(Linked<T> node) { AnnotationMap ann = node.value.getAllAnnotations(); if (node.next != null) { ann = AnnotationMap.merge(ann, _getAllAnnotations(node.next)); } return ann; } /** * Helper method to handle recursive merging of annotations within accessor class, * to ensure no annotations are accidentally dropped within chain when non-visible * and secondary accessors are pruned later on. *<p> * See [databind#868] for more information. * * @since 2.6 */ private <T extends AnnotatedMember> Linked<T> _applyAnnotations(Linked<T> node, AnnotationMap ann) { @SuppressWarnings("unchecked") T value = (T) node.value.withAnnotations(ann); if (node.next != null) { node = node.withNext(_applyAnnotations(node.next, ann)); } return node.withValue(value); } private <T> Linked<T> _removeIgnored(Linked<T> node) { if (node == null) { return node; } return node.withoutIgnored(); } private <T> Linked<T> _removeNonVisible(Linked<T> node) { if (node == null) { return node; } return node.withoutNonVisible(); }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> private <T> Linked<T> _trimByVisibility(Linked<T> node) { if (node == null) { return node; } return node.trimByVisibility(); } /* /********************************************************** /* Accessors for aggregate information /********************************************************** */ private <T> boolean _anyExplicits(Linked<T> n) { for (; n != null; n = n.next) { if (n.name != null && n.name.hasSimpleName()) { return true; } } return false; } private <T> boolean _anyExplicitNames(Linked<T> n) { for (; n != null; n = n.next) { if (n.name != null && n.isNameExplicit) { return true; } } return false; } public boolean anyVisible() { return _anyVisible(_fields) || _anyVisible(_getters) || _anyVisible(_setters) || _anyVisible(_ctorParameters) ; } private <T> boolean _anyVisible(Linked<T> n) { for (; n != null; n = n.next) { if (n.isVisible) { return true; } } return false; } public boolean anyIgnorals() { return _anyIgnorals(_fields) || _anyIgnorals(_getters) || _anyIgnorals(_setters) || _anyIgnorals(_ctorParameters) ; } private <T> boolean _anyIgnorals(Linked<T> n) { for (; n != null; n = n.next) { if (n.isMarkedIgnored) { return true; } } return false; } /** * Method called to find out set of explicit names for accessors * bound together due to implicit name. * * @since 2.4 */ public Set<PropertyName> findExplicitNames() { Set<PropertyName> renamed = null; renamed = _findExplicitNames(_fields, renamed); renamed = _findExplicitNames(_getters, renamed); renamed = _findExplicitNames(_setters, renamed); renamed = _findExplicitNames(_ctorParameters, renamed); if (renamed == null) { return Collections.emptySet(); } return renamed; } /** * Method called when a previous call to {@link #findExplicitNames} found * multiple distinct explicit names, and the property this builder represents * basically needs to be broken apart and replaced by a set of more than * one properties. * * @since 2.4 */ public Collection<POJOPropertyBuilder> explode(Collection<PropertyName> newNames) { HashMap

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS><PropertyName,POJOPropertyBuilder> props = new HashMap<PropertyName,POJOPropertyBuilder>(); _explode(newNames, props, _fields); _explode(newNames, props, _getters); _explode(newNames, props, _setters); _explode(newNames, props, _ctorParameters); return props.values(); } @SuppressWarnings("unchecked") private void _explode(Collection<PropertyName> newNames, Map<PropertyName,POJOPropertyBuilder> props, Linked<?> accessors) { final Linked<?> firstAcc = accessors; // clumsy, part 1 for (Linked<?> node = accessors; node != null; node = node.next) { PropertyName name = node.name; if (!node.isNameExplicit || name == null) { // no explicit name -- problem! // [databind#541] ... but only as long as it's visible if (!node.isVisible) { continue; } throw new IllegalStateException("Conflicting/ambiguous property name definitions (implicit name '" +_name+"'): found multiple explicit names: " +newNames+", but also implicit accessor: "+node); } POJOPropertyBuilder prop = props.get(name); if (prop == null) { prop = new POJOPropertyBuilder(_config, _annotationIntrospector, _forSerialization, _internalName, name); props.put(name, prop); } // ultra-clumsy, part 2 -- lambdas would be nice here if (firstAcc == _fields) { Linked<AnnotatedField> n2 = (Linked<AnnotatedField>) node; prop._fields = n2.withNext(prop._fields); } else if (firstAcc == _getters) { Linked<AnnotatedMethod> n2 = (Linked<AnnotatedMethod>) node; prop._getters = n2.withNext(prop._getters); } else if (firstAcc == _setters) { Linked<AnnotatedMethod> n2 = (Linked<AnnotatedMethod>) node; prop._setters = n2.withNext(prop._setters); } else if (firstAcc == _ctorParameters) { Linked<AnnotatedParameter> n2 = (Linked<AnnotatedParameter>) node; prop._ctorParameters = n2.withNext(prop._ctorParameters); } else { throw new IllegalStateException("Internal error: mismatched accessors, property: "+this); } } } private Set<PropertyName> _findExplicitNames(Linked<? extends AnnotatedMember> node, Set<PropertyName> renamed) { for (; node != null; node = node.next) { /* 30-Mar-2014, tatu: Second check should not be needed, but seems like * removing it can cause nasty

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> { T result = func.withMember(_setters.value); if ((result != null) && (result != defaultValue)) { return result; } } return null; } if (_ctorParameters != null) { T result = func.withMember(_ctorParameters.value); if ((result != null) && (result != defaultValue)) { return result; } } if (_setters != null) { T result = func.withMember(_setters.value); if ((result != null) && (result != defaultValue)) { return result; } } if (_fields != null) { T result = func.withMember(_fields.value); if ((result != null) && (result != defaultValue)) { return result; } } if (_getters != null) { T result = func.withMember(_getters.value); if ((result != null) && (result != defaultValue)) { return result; } } return null; } /* /********************************************************** /* Helper classes /********************************************************** */ private interface WithMember<T> { public T withMember(AnnotatedMember member); } /** * @since 2.5 */ protected static class MemberIterator<T extends AnnotatedMember> implements Iterator<T> { private Linked<T> next; public MemberIterator(Linked<T> first) { next = first; } @Override public boolean hasNext() { return (next != null); } @Override public T next() { if (next == null) throw new NoSuchElementException(); T result = next.value; next = next.next; return result; } @Override public void remove() { throw new UnsupportedOperationException(); } } /** * Node used for creating simple linked lists to efficiently store small sets * of things. */ protected final static class Linked<T> { public final T value; public final Linked<T> next; public final PropertyName name; public final boolean isNameExplicit; public final boolean isVisible; public final boolean isMarkedIgnored; public Linked(T v, Linked<T> n, PropertyName name, boolean explName, boolean visible, boolean ignored) { value = v; next = n; // ensure that we'll never have missing names this.name = (name == null || name.isEmpty()) ? null : name; if (explName) { if (this.name == null) { // sanity check to catch internal problems throw new IllegalArgumentException("Can not pass true for 'explName' if name is null/empty"); } // 03-Apr-2014, tatu: But how about name-space only override?

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> // Probably should not be explicit? Or, need to merge somehow? if (!name.hasSimpleName()) { explName = false; } } isNameExplicit = explName; isVisible = visible; isMarkedIgnored = ignored; } public Linked<T> withoutNext() { if (next == null) { return this; } return new Linked<T>(value, null, name, isNameExplicit, isVisible, isMarkedIgnored); } public Linked<T> withValue(T newValue) { if (newValue == value) { return this; } return new Linked<T>(newValue, next, name, isNameExplicit, isVisible, isMarkedIgnored); } public Linked<T> withNext(Linked<T> newNext) { if (newNext == next) { return this; } return new Linked<T>(value, newNext, name, isNameExplicit, isVisible, isMarkedIgnored); } public Linked<T> withoutIgnored() { if (isMarkedIgnored) { return (next == null) ? null : next.withoutIgnored(); } if (next != null) { Linked<T> newNext = next.withoutIgnored(); if (newNext != next) { return withNext(newNext); } } return this; } public Linked<T> withoutNonVisible() { Linked<T> newNext = (next == null) ? null : next.withoutNonVisible(); return isVisible ? withNext(newNext) : newNext; } /** * Method called to append given node(s) at the end of this * node chain. */ protected Linked<T> append(Linked<T> appendable) { if (next == null) { return withNext(appendable); } return withNext(next.append(appendable)); } public Linked<T> trimByVisibility() { if (next == null) { return this; } Linked<T> newNext = next.trimByVisibility(); if (name != null) { // this already has highest; how about next one? if (newNext.name == null) { // next one not, drop it return withNext(null); } // both have it, keep return withNext(newNext); } if (newNext.name != null) { // next one has higher, return it... return newNext; } // neither has explicit name; how about visibility? if (isVisible == newNext.isVisible) { // same; keep both in current order return withNext(newNext); } return isVisible ? withNext(null) : newNext; } @Override public String toString() { String msg = value

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>.toString()+"[visible="+isVisible+",ignore="+isMarkedIgnored +",explicitName="+isNameExplicit+"]"; if (next != null) { msg = msg + ", "+next.toString(); } return msg; } } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.util; /** * Node of a forward-only linked list. * * @author tatu * * @param <T> Type of contained object */ public final class LinkedNode<T> { private final T value; private LinkedNode<T> next; public LinkedNode(T value, LinkedNode<T> next) { this.value = value; this.next = next; } public void linkNext(LinkedNode<T> n) { if (next != null) { // sanity check throw new IllegalStateException(); } next = n; } public LinkedNode<T> next() { return next; } public T value() { return value; } /** * Convenience method that can be used to check if a linked list * with given head node (which may be null to indicate empty list) * contains given value * * @param <ST> Type argument that defines contents of the linked list parameter * @param node Head node of the linked list * @param value Value to look for * @return True if linked list contains the value, false otherwise */ public static <ST> boolean contains(LinkedNode<ST> node, ST value) { while (node != null) { if (node.value() == value) { return true; } node = node.next(); } return false; } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>: "); sb = getPathReference(sb); sb.append(')'); return sb.toString(); } @Override public String toString() { return getClass().getName()+": "+getMessage(); } /* /********************************************************** /* Internal methods /********************************************************** */ protected void _appendPathDesc(StringBuilder sb) { if (_path == null) { return; } Iterator<Reference> it = _path.iterator(); while (it.hasNext()) { sb.append(it.next().toString()); if (it.hasNext()) { sb.append("->"); } } } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { // In future could check current token... for now this should be enough: return typeDeserializer.deserializeTypedFromArray(jp, ctxt); } /** * Helper method called when current token is no START_ARRAY. Will either * throw an exception, or try to handle value as if member of implicit * array, depending on configuration. */ protected final Collection<Object> handleNonArray(JsonParser p, DeserializationContext ctxt, Collection<Object> result) throws IOException { // Implicit arrays from single values? boolean canWrap = (_unwrapSingle == Boolean.TRUE) || ((_unwrapSingle == null) && ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)); if (!canWrap) { throw ctxt.mappingException(_collectionType.getRawClass()); } JsonDeserializer<Object> valueDes = _valueDeserializer; final TypeDeserializer typeDeser = _valueTypeDeserializer; JsonToken t = p.getCurrentToken(); Object value; try { if (t == JsonToken.VALUE_NULL) { value = valueDes.getNullValue(ctxt); } else if (typeDeser == null) { value = valueDes.deserialize(p, ctxt); } else { value = valueDes.deserializeWithType(p, ctxt, typeDeser); } } catch (Exception e) { // note: pass Object.class, not Object[].class, as we need element type for error info throw JsonMappingException.wrapWithPath(e, Object.class, result.size()); } result.add(value); return result; } public final static class CollectionReferringAccumulator { private final Class<?> _elementType; private final Collection<Object> _result; /** * A list of {@link CollectionReferring} to maintain ordering. */ private List<CollectionReferring> _accumulator = new ArrayList<CollectionReferring>(); public CollectionReferringAccumulator(Class<?> elementType, Collection<Object> result) { _elementType = elementType; _result = result; } public void add(Object value) { if (_accumulator.isEmpty()) { _result.add(value); } else { CollectionReferring ref = _accumulator.get(_accumulator.size() - 1); ref.next.add(value); } } public Referring handleUnresolvedReference(UnresolvedForwardReference reference) { CollectionReferring id = new CollectionReferring(this, reference, _elementType); _accumulator.add(id); return id; } public void resolveForwardReference(Object id, Object value) throws IOException { Iterator<CollectionReferring> iterator = _accumulator.

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>iterator(); // Resolve ordering after resolution of an id. This mean either: // 1- adding to the result collection in case of the first unresolved id. // 2- merge the content of the resolved id with its previous unresolved id. Collection<Object> previous = _result; while (iterator.hasNext()) { CollectionReferring ref = iterator.next(); if (ref.hasId(id)) { iterator.remove(); previous.add(value); previous.addAll(ref.next); return; } previous = ref.next; } throw new IllegalArgumentException("Trying to resolve a forward reference with id [" + id + "] that wasn't previously seen as unresolved."); } } /** * Helper class to maintain processing order of value. The resolved * object associated with {@link #_id} comes before the values in * {@link #next}. */ private final static class CollectionReferring extends Referring { private final CollectionReferringAccumulator _parent; public final List<Object> next = new ArrayList<Object>(); CollectionReferring(CollectionReferringAccumulator parent, UnresolvedForwardReference reference, Class<?> contentType) { super(reference, contentType); _parent = parent; } @Override public void handleResolvedForwardReference(Object id, Object value) throws IOException { _parent.resolveForwardReference(id, value); } } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> } } props.add(prop); } if (!found) { throw new NoSuchElementException("No entry '"+propToRm.getName()+"' found, can't remove"); } init(props); } /** * Convenience method that tries to find property with given name, and * if it is found, call {@link SettableBeanProperty#deserializeAndSet} * on it, and return true; or, if not found, return false. * Note, too, that if deserialization is attempted, possible exceptions * are wrapped if and as necessary, so caller need not handle those. * * @since 2.5 */ public boolean findDeserializeAndSet(JsonParser p, DeserializationContext ctxt, Object bean, String key) throws IOException { final SettableBeanProperty prop = find(key); if (prop == null) { return false; } try { prop.deserializeAndSet(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, key, ctxt); } return true; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Properties=["); int count = 0; Iterator<SettableBeanProperty> it = iterator(); while (it.hasNext()) { SettableBeanProperty prop = it.next(); if (count++ > 0) { sb.append(", "); } sb.append(prop.getName()); sb.append('('); sb.append(prop.getType()); sb.append(')'); } sb.append(']'); return sb.toString(); } /* /********************************************************** /* Helper methods /********************************************************** */ protected SettableBeanProperty _rename(SettableBeanProperty prop, NameTransformer xf) { if (prop == null) { return prop; } String newName = xf.transform(prop.getName()); prop = prop.withSimpleName(newName); JsonDeserializer<?> deser = prop.getValueDeserializer(); if (deser != null) { @SuppressWarnings("unchecked") JsonDeserializer<Object> newDeser = (JsonDeserializer<Object>) deser.unwrappingDeserializer(xf); if (newDeser != deser) { prop = prop.withValueDeserializer(newDeser); } } return prop; } protected void wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws IOException { // inlined 'throwOrReturnThrowable' while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors to be passed as is if (t instanceof Error) { throw (Error) t; } // StackOverflowErrors are tricky ones;

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>withAdditionalDeserializers(additional)); } /** * Convenience method for creating a new factory instance with additional * {@link KeyDeserializers}. */ @Override public final DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional) { return withConfig(_factoryConfig.withAdditionalKeyDeserializers(additional)); } /** * Convenience method for creating a new factory instance with additional * {@link BeanDeserializerModifier}. */ @Override public final DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier) { return withConfig(_factoryConfig.withDeserializerModifier(modifier)); } /** * Convenience method for creating a new factory instance with additional * {@link AbstractTypeResolver}. */ @Override public final DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver) { return withConfig(_factoryConfig.withAbstractTypeResolver(resolver)); } /** * Convenience method for creating a new factory instance with additional * {@link ValueInstantiators}. */ @Override public final DeserializerFactory withValueInstantiators(ValueInstantiators instantiators) { return withConfig(_factoryConfig.withValueInstantiators(instantiators)); } /* /********************************************************** /* DeserializerFactory impl (partial): type mappings /********************************************************** */ @Override public JavaType mapAbstractType(DeserializationConfig config, JavaType type) throws JsonMappingException { // first, general mappings while (true) { JavaType next = _mapAbstractType2(config, type); if (next == null) { return type; } // Should not have to worry about cycles; but better verify since they will invariably occur... :-) // (also: guard against invalid resolution to a non-related type) Class<?> prevCls = type.getRawClass(); Class<?> nextCls = next.getRawClass(); if ((prevCls == nextCls) || !prevCls.isAssignableFrom(nextCls)) { throw new IllegalArgumentException("Invalid abstract type resolution from "+type+" to "+next+": latter is not a subtype of former"); } type = next; } } /** * Method that will find abstract type mapping for specified type, doing a single * lookup through registered abstract type resolvers; will not do recursive lookups. */ private JavaType _mapAbstractType2(DeserializationConfig config, JavaType type) throws JsonMappingException { Class<?> currClass = type.getRawClass(); if (_factoryConfig.hasAbstractTypeResolvers()) { for (AbstractTypeResolver resolver : _factoryConfig.abstractTypeResolvers()) { JavaType concrete = resolver.findTypeMapping(config, type); if (concrete != null && concrete.getRawClass() != currClass) { return concrete; } } } return null; } /* /********************************************************** /* JsonDeserializerFactory impl (partial

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>()); AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); // need to construct suitable visibility checker: final DeserializationConfig config = ctxt.getConfig(); VisibilityChecker<?> vchecker = config.getDefaultVisibilityChecker(); vchecker = intr.findAutoDetectVisibility(beanDesc.getClassInfo(), vchecker); /* 24-Sep-2014, tatu: Tricky part first; need to merge resolved property information * (which has creator parameters sprinkled around) with actual creator * declarations (which are needed to access creator annotation, amongst other things). * Easiest to combine that info first, then pass it to remaining processing. */ /* 15-Mar-2015, tatu: Alas, this won't help with constructors that only have implicit * names. Those will need to be resolved later on. */ Map<AnnotatedWithParams,BeanPropertyDefinition[]> creatorDefs = _findCreatorsFromProperties(ctxt, beanDesc); /* Important: first add factory methods; then constructors, so * latter can override former! */ _addDeserializerFactoryMethods(ctxt, beanDesc, vchecker, intr, creators, creatorDefs); // constructors only usable on concrete types: if (beanDesc.getType().isConcrete()) { _addDeserializerConstructors(ctxt, beanDesc, vchecker, intr, creators, creatorDefs); } return creators.constructValueInstantiator(config); } protected Map<AnnotatedWithParams,BeanPropertyDefinition[]> _findCreatorsFromProperties(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException { Map<AnnotatedWithParams,BeanPropertyDefinition[]> result = Collections.emptyMap(); for (BeanPropertyDefinition propDef : beanDesc.findProperties()) { Iterator<AnnotatedParameter> it = propDef.getConstructorParameters(); while (it.hasNext()) { AnnotatedParameter param = it.next(); AnnotatedWithParams owner = param.getOwner(); BeanPropertyDefinition[] defs = result.get(owner); final int index = param.getIndex(); if (defs == null) { if (result.isEmpty()) { // since emptyMap is immutable need to create a 'real' one result = new LinkedHashMap<AnnotatedWithParams,BeanPropertyDefinition[]>(); } defs = new BeanPropertyDefinition[owner.getParameterCount()]; result.put(owner, defs); } else { if (defs[index] != null) { throw new IllegalStateException("Conflict: parameter #"+index+" of "+owner +" bound to more than one property; "+defs[index]+" vs "+propDef); } } defs[index] = propDef; } } return result; } public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config, Annotated annotated, Object instDef

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>) throws JsonMappingException { if (instDef == null) { return null; } ValueInstantiator inst; if (instDef instanceof ValueInstantiator) { return (ValueInstantiator) instDef; } if (!(instDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned key deserializer definition of type " +instDef.getClass().getName() +"; expected type KeyDeserializer or Class<KeyDeserializer> instead"); } Class<?> instClass = (Class<?>)instDef; if (ClassUtil.isBogusClass(instClass)) { return null; } if (!ValueInstantiator.class.isAssignableFrom(instClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+instClass.getName() +"; expected Class<ValueInstantiator>"); } HandlerInstantiator hi = config.getHandlerInstantiator(); if (hi != null) { inst = hi.valueInstantiatorInstance(config, annotated, instClass); if (inst != null) { return inst; } } return (ValueInstantiator) ClassUtil.createInstance(instClass, config.canOverrideAccessModifiers()); } protected void _addDeserializerConstructors (DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, Map<AnnotatedWithParams,BeanPropertyDefinition[]> creatorParams) throws JsonMappingException { // First things first: the "default constructor" (zero-arg // constructor; whether implicit or explicit) is NOT included // in list of constructors, so needs to be handled separately. AnnotatedConstructor defaultCtor = beanDesc.findDefaultConstructor(); if (defaultCtor != null) { if (!creators.hasDefaultCreator() || intr.hasCreatorAnnotation(defaultCtor)) { creators.setDefaultCreator(defaultCtor); } } // may need to keep track for [#725] List<AnnotatedConstructor> implicitCtors = null; for (AnnotatedConstructor ctor : beanDesc.getConstructors()) { final boolean isCreator = intr.hasCreatorAnnotation(ctor); BeanPropertyDefinition[] propDefs = creatorParams.get(ctor); final int argCount = ctor.getParameterCount(); // some single-arg factory methods (String, number) are auto-detected if (argCount == 1) { BeanPropertyDefinition argDef = (propDefs == null) ? null : propDefs[0]; boolean useProps = _checkIfCreatorPropertyBased(intr, ctor, argDef); if (useProps) { SettableBeanProperty[] properties = new SettableBeanProperty[1]; PropertyName name = (argDef == null) ? null : argDef.getFullName(); AnnotatedParameter arg = ctor.getParameter(0); properties[0

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> } } deser = new ObjectArrayDeserializer(type, contentDeser, elemTypeDeser); } // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyArrayDeserializer(config, type, beanDesc, deser); } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: Collection(-like) deserializers /********************************************************** */ @Override public JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc) throws JsonMappingException { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); final DeserializationConfig config = ctxt.getConfig(); // Then optional type info: if type has been resolved, we may already know type deserializer: TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); // but if not, may still be possible to find: if (contentTypeDeser == null) { contentTypeDeser = findTypeDeserializer(config, contentType); } // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> deser = _findCustomCollectionDeserializer(type, config, beanDesc, contentTypeDeser, contentDeser); if (deser == null) { Class<?> collectionClass = type.getRawClass(); if (contentDeser == null) { // not defined by annotation // One special type: EnumSet: if (EnumSet.class.isAssignableFrom(collectionClass)) { deser = new EnumSetDeserializer(contentType, null); } } } /* One twist: if we are being asked to instantiate an interface or * abstract Collection, we need to either find something that implements * the thing, or give up. * * Note that we do NOT try to guess based on secondary interfaces * here; that would probably not work correctly since casts would * fail later on (as the primary type is not the interface we'd * be implementing) */ if (deser == null) { if (type.isInterface() || type.isAbstract()) { CollectionType implType = _mapAbstractCollectionType(type, config); if (implType == null) { // [databind#292]: Actually, may be fine, but only if polymorphich deser enabled if (type.getTypeHandler() == null) { throw new IllegalArgumentException("Can not find a deserializer for non-concrete Collection type "+type); } deser = AbstractDeserializer.constructForNonPOJO(beanDesc); } else

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyCollectionLikeDeserializer(config, type, beanDesc, deser); } } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: Map(-like) deserializers /********************************************************** */ @Override public JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); JavaType keyType = type.getKeyType(); JavaType contentType = type.getContentType(); // First: is there annotation-specified deserializer for values? @SuppressWarnings("unchecked") JsonDeserializer<Object> contentDeser = (JsonDeserializer<Object>) contentType.getValueHandler(); // Ok: need a key deserializer (null indicates 'default' here) KeyDeserializer keyDes = (KeyDeserializer) keyType.getValueHandler(); // Then optional type info (1.5); either attached to type, or resolved separately: TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); // but if not, may still be possible to find: if (contentTypeDeser == null) { contentTypeDeser = findTypeDeserializer(config, contentType); } // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> deser = _findCustomMapDeserializer(type, config, beanDesc, keyDes, contentTypeDeser, contentDeser); if (deser == null) { // Value handling is identical for all, but EnumMap requires special handling for keys Class<?> mapClass = type.getRawClass(); if (EnumMap.class.isAssignableFrom(mapClass)) { Class<?> kt = keyType.getRawClass(); if (kt == null || !kt.isEnum()) { throw new IllegalArgumentException("Can not construct EnumMap; generic (key) type not available"); } deser = new EnumMapDeserializer(type, null, contentDeser, contentTypeDeser); } // Otherwise, generic handler works ok. /* But there is one more twist: if we are being asked to instantiate * an interface or abstract Map, we need to either find something * that implements the thing, or give up. * * Note that we do NOT try to guess based on secondary interfaces * here; that would probably not work correctly since casts would * fail later on (as the primary type is not the interface we'd * be implementing) */ if (deser == null) { if (type.isInterface() || type.isAbstract()) { @SuppressWarnings("rawtypes") Class<? extends Map> fallback = _mapFallbacks.get(mapClass.getName()); if (fallback != null) { mapClass = fallback; type = (MapType)

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> (deser != null) { // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyMapLikeDeserializer(config, type, beanDesc, deser); } } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: other types /********************************************************** */ /** * Factory method for constructing serializers of {@link Enum} types. */ @Override public JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); final Class<?> enumClass = type.getRawClass(); // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> deser = _findCustomEnumDeserializer(enumClass, config, beanDesc); if (deser == null) { // May have @JsonCreator for static factory method: for (AnnotatedMethod factory : beanDesc.getFactoryMethods()) { if (ctxt.getAnnotationIntrospector().hasCreatorAnnotation(factory)) { int argCount = factory.getParameterCount(); if (argCount == 1) { Class<?> returnType = factory.getRawReturnType(); // usually should be class, but may be just plain Enum<?> (for Enum.valueOf()?) if (returnType.isAssignableFrom(enumClass)) { deser = EnumDeserializer.deserializerForCreator(config, enumClass, factory); break; } } throw new IllegalArgumentException("Unsuitable method ("+factory+") decorated with @JsonCreator (for Enum type " +enumClass.getName()+")"); } } // Need to consider @JsonValue if one found if (deser == null) { deser = new EnumDeserializer(constructEnumResolver(enumClass, config, beanDesc.findJsonValueMethod())); } } // and then post-process it too if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyEnumDeserializer(config, type, beanDesc, deser); } } return deser; } @Override public JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config, JavaType nodeType, BeanDescription beanDesc) throws JsonMappingException { @SuppressWarnings("unchecked") Class<? extends JsonNode> nodeClass = (Class<? extends JsonNode>) nodeType.getRawClass(); // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> custom = _findCustomTreeNodeDeserializer(nodeClass, config, beanDesc); if (custom != null) { return

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> custom; } return JsonNodeDeserializer.getDeserializer(nodeClass); } @Override public JsonDeserializer<?> createReferenceDeserializer(DeserializationContext ctxt, ReferenceType type, BeanDescription beanDesc) throws JsonMappingException { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); final DeserializationConfig config = ctxt.getConfig(); // Then optional type info: if type has been resolved, we may already know type deserializer: TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); if (contentTypeDeser == null) { // or if not, may be able to find: contentTypeDeser = findTypeDeserializer(config, contentType); } JsonDeserializer<?> deser = _findCustomReferenceDeserializer(type, config, beanDesc, contentTypeDeser, contentDeser); if (deser == null) { // Just one referential type as of JDK 1.7 / Java 7: AtomicReference (Java 8 adds Optional) if (AtomicReference.class.isAssignableFrom(type.getRawClass())) { JavaType referencedType = type.getReferencedType(); /* TypeDeserializer vts = findTypeDeserializer(ctxt.getConfig(), referencedType); BeanDescription refdDesc = ctxt.getConfig().introspectClassAnnotations(referencedType); JsonDeserializer<?> deser = findDeserializerFromAnnotation(ctxt, refdDesc.getClassInfo()); */ return new AtomicReferenceDeserializer(referencedType, contentTypeDeser, deser); } } if (deser != null) { // and then post-process if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyReferenceDeserializer(config, type, beanDesc, deser); } } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl (partial): type deserializers /********************************************************** */ @Override public TypeDeserializer findTypeDeserializer(DeserializationConfig config, JavaType baseType) throws JsonMappingException { BeanDescription bean = config.introspectClassAnnotations(baseType.getRawClass()); AnnotatedClass ac = bean.getClassInfo(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findTypeResolver(config, ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default. If so, config object knows what to use. */ Collection<NamedType> subtypes = null; if (b == null) { b = config.getDefaultTyper(baseType); if (b == null) { return null; } } else { subtypes = config.getSubtypeResolver().

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> beanDesc.getClassInfo()); if (des != null) { return des; } else { // 24-Sep-2015, bim: if no key deser, look for enum deserializer first, then a plain deser. JsonDeserializer<?> custom = _findCustomEnumDeserializer(enumClass, config, beanDesc); if (custom != null) { return StdKeyDeserializers.constructDelegatingKeyDeserializer(config, type, custom); } JsonDeserializer<?> valueDesForKey = findDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo()); if (valueDesForKey != null) { return StdKeyDeserializers.constructDelegatingKeyDeserializer(config, type, valueDesForKey); } } EnumResolver enumRes = constructEnumResolver(enumClass, config, beanDesc.findJsonValueMethod()); // May have @JsonCreator for static factory method: final AnnotationIntrospector ai = config.getAnnotationIntrospector(); for (AnnotatedMethod factory : beanDesc.getFactoryMethods()) { if (ai.hasCreatorAnnotation(factory)) { int argCount = factory.getParameterCount(); if (argCount == 1) { Class<?> returnType = factory.getRawReturnType(); // usually should be class, but may be just plain Enum<?> (for Enum.valueOf()?) if (returnType.isAssignableFrom(enumClass)) { // note: mostly copied from 'EnumDeserializer.deserializerForCreator(...)' if (factory.getRawParameterType(0) != String.class) { throw new IllegalArgumentException("Parameter #0 type for factory method ("+factory+") not suitable, must be java.lang.String"); } if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(factory.getMember(), ctxt.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } return StdKeyDeserializers.constructEnumKeyDeserializer(enumRes, factory); } } throw new IllegalArgumentException("Unsuitable method ("+factory+") decorated with @JsonCreator (for Enum type " +enumClass.getName()+")"); } } // [JACKSON-749] Also, need to consider @JsonValue, if one found return StdKeyDeserializers.constructEnumKeyDeserializer(enumRes); } /* /********************************************************** /* Extended API /********************************************************** */ /** * Method called to create a type information deserializer for values of * given non-container property, if one is needed. * If not needed (no polymorphic handling configured for property), should return null. *<p> * Note that this method is only called for non-container bean properties, * and not for values in container types or root values (or container properties) * * @param baseType Declared base type of the value to deserializer (actual * deserializer

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> value.iterator(); if (!it.hasNext()) { return false; } it.next(); return !it.hasNext(); } /* /********************************************************** /* Actual serialization /********************************************************** */ @Override public final void serialize(Collection<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException { final int len = value.size(); if (len == 1) { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { serializeContents(value, jgen, provider); return; } } jgen.writeStartArray(len); serializeContents(value, jgen, provider); jgen.writeEndArray(); } @Override public void serializeContents(Collection<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (_elementSerializer != null) { serializeContentsUsing(value, jgen, provider, _elementSerializer); return; } Iterator<?> it = value.iterator(); if (!it.hasNext()) { return; } PropertySerializerMap serializers = _dynamicSerializers; final TypeSerializer typeSer = _valueTypeSerializer; int i = 0; try { do { Object elem = it.next(); if (elem == null) { provider.defaultSerializeNull(jgen); } else { Class<?> cc = elem.getClass(); JsonSerializer<Object> serializer = serializers.serializerFor(cc); if (serializer == null) { if (_elementType.hasGenericTypes()) { serializer = _findAndAddDynamic(serializers, provider.constructSpecializedType(_elementType, cc), provider); } else { serializer = _findAndAddDynamic(serializers, cc, provider); } serializers = _dynamicSerializers; } if (typeSer == null) { serializer.serialize(elem, jgen, provider); } else { serializer.serializeWithType(elem, jgen, provider, typeSer); } } ++i; } while (it.hasNext()); } catch (Exception e) { wrapAndThrow(provider, e, value, i); } } public void serializeContentsUsing(Collection<?> value, JsonGenerator jgen, SerializerProvider provider, JsonSerializer<Object> ser) throws IOException, JsonGenerationException { Iterator<?> it = value.iterator(); if (it.hasNext()) { TypeSerializer typeSer = _valueTypeSerializer; int i = 0; do { Object elem = it.next(); try { if (elem == null) { provider.defaultSerializeNull(jgen); } else { if (typeSer == null) { ser.serialize(elem

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> used when we must be using some form of * abstract resolution, usually by using addition Type Id * ("polymorphic deserialization") * * @since 2.0 */ public AbstractDeserializer buildAbstract() { return new AbstractDeserializer(this, _beanDesc, _backRefProperties); } /** * Method for constructing a specialized deserializer that uses * additional external Builder object during data binding. */ public JsonDeserializer<?> buildBuilderBased(JavaType valueType, String expBuildMethodName) { // First: validation; must have build method that returns compatible type if (_buildMethod == null) { // as per [databind#777], allow empty name if (!expBuildMethodName.isEmpty()) { throw new IllegalArgumentException("Builder class "+_beanDesc.getBeanClass().getName() +" does not have build method (name: '"+expBuildMethodName+"')"); } } else { // also: type of the method must be compatible Class<?> rawBuildType = _buildMethod.getRawReturnType(); Class<?> rawValueType = valueType.getRawClass(); if ((rawBuildType != rawValueType) && !rawBuildType.isAssignableFrom(rawValueType) && !rawValueType.isAssignableFrom(rawBuildType)) { throw new IllegalArgumentException("Build method '"+_buildMethod.getFullName() +" has bad return type ("+rawBuildType.getName() +"), not compatible with POJO type ("+valueType.getRawClass().getName()+")"); } } // And if so, we can try building the deserializer Collection<SettableBeanProperty> props = _properties.values(); BeanPropertyMap propertyMap = BeanPropertyMap.construct(props, _caseInsensitivePropertyComparison); propertyMap.assignIndexes(); boolean anyViews = !_defaultViewInclusion; if (!anyViews) { for (SettableBeanProperty prop : props) { if (prop.hasViews()) { anyViews = true; break; } } } if (_objectIdReader != null) { /* 18-Nov-2012, tatu: May or may not have annotations for id property; * but no easy access. But hard to see id property being optional, * so let's consider required at this point. */ ObjectIdValueProperty prop = new ObjectIdValueProperty(_objectIdReader, PropertyMetadata.STD_REQUIRED); propertyMap = propertyMap.withProperty(prop); } return new BuilderBasedDeserializer(this, _beanDesc, propertyMap, _backRefProperties, _ignorableProps, _ignoreAllUnknown, anyViews); } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.deser; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.fasterxml.jackson.core.JsonLocation; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.deser.impl.ReadableObjectId; /** * Exception thrown during deserialization when there are object id that can't * be resolved. * * @author pgelinas */ public class UnresolvedForwardReference extends JsonMappingException { private static final long serialVersionUID = 1L; private ReadableObjectId _roid; private List<UnresolvedId> _unresolvedIds; /** * @since 2.7 */ public UnresolvedForwardReference(JsonParser p, String msg, JsonLocation loc, ReadableObjectId roid) { super(p, msg, loc); _roid = roid; } /** * @since 2.7 */ public UnresolvedForwardReference(JsonParser p, String msg) { super(p, msg); _unresolvedIds = new ArrayList<UnresolvedId>(); } /** * @deprecated Since 2.7 */ @Deprecated // since 2.7 public UnresolvedForwardReference(String msg, JsonLocation loc, ReadableObjectId roid) { super(msg, loc); _roid = roid; } /** * @deprecated Since 2.7 */ @Deprecated // since 2.7 public UnresolvedForwardReference(String msg) { super(msg); _unresolvedIds = new ArrayList<UnresolvedId>(); } /* /********************************************************** /* Accessor methods /********************************************************** */ public ReadableObjectId getRoid() { return _roid; } public Object getUnresolvedId() { return _roid.getKey().key; } public void addUnresolvedId(Object id, Class<?> type, JsonLocation where) { _unresolvedIds.add(new UnresolvedId(id, type, where)); } public List<UnresolvedId> getUnresolvedIds(){ return _unresolvedIds; } @Override public String getMessage() { String msg = super.getMessage(); if (_unresolvedIds == null) { return msg; } StringBuilder sb = new StringBuilder(msg); Iterator<UnresolvedId> iterator = _unresolvedIds.iterator(); while (iterator.hasNext()) { UnresolvedId unresolvedId = iterator.next(); sb.append(unresolvedId.toString()); if (iterator.hasNext()) { sb.append(", "); } } sb.append('.'); return sb.toString(); }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>Parser jp, DeserializationContext ctxt) throws IOException; /** * Method called to let this type deserializer handle * deserialization of "typed" object, when value itself * is serialized as JSON Array (regardless of Java type). * Method needs to figure out intended * polymorphic type, locate {@link JsonDeserializer} to use, and * call it with JSON data to deserializer (which does not contain * type information). */ public abstract Object deserializeTypedFromArray(JsonParser jp, DeserializationContext ctxt) throws IOException; /** * Method called to let this type deserializer handle * deserialization of "typed" object, when value itself * is serialized as a scalar JSON value (something other * than Array or Object), regardless of Java type. * Method needs to figure out intended * polymorphic type, locate {@link JsonDeserializer} to use, and * call it with JSON data to deserializer (which does not contain * type information). */ public abstract Object deserializeTypedFromScalar(JsonParser jp, DeserializationContext ctxt) throws IOException; /** * Method called to let this type deserializer handle * deserialization of "typed" object, when value itself * may have been serialized using any kind of JSON value * (Array, Object, scalar). Should only be called if JSON * serialization is polymorphic (not Java type); for example when * using JSON node representation, or "untyped" Java object * (which may be Map, Collection, wrapper/primitive etc). */ public abstract Object deserializeTypedFromAny(JsonParser jp, DeserializationContext ctxt) throws IOException; /* /********************************************************** /* Shared helper methods /********************************************************** */ /** * Helper method used to check if given parser might be pointing to * a "natural" value, and one that would be acceptable as the * result value (compatible with declared base type) */ public static Object deserializeIfNatural(JsonParser jp, DeserializationContext ctxt, JavaType baseType) throws IOException { return deserializeIfNatural(jp, ctxt, baseType.getRawClass()); } @SuppressWarnings("incomplete-switch") public static Object deserializeIfNatural(JsonParser jp, DeserializationContext ctxt, Class<?> base) throws IOException { JsonToken t = jp.getCurrentToken(); if (t == null) { return null; } switch (t) { case VALUE_STRING: if (base.isAssignableFrom(String.class)) { return jp.getText(); } break; case VALUE_NUMBER_INT: if (base.isAssignableFrom(Integer.class)) { return jp.getIntValue(); } break; case VALUE_NUMBER_FLOAT: if (base.isAssignableFrom(Double.class)) { return Double.valueOf(jp.getDoubleValue()); } break; case VALUE_TRUE

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>: if (base.isAssignableFrom(Boolean.class)) { return Boolean.TRUE; } break; case VALUE_FALSE: if (base.isAssignableFrom(Boolean.class)) { return Boolean.FALSE; } break; } return null; } }

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>canWriteObjectId(); } _mayHaveNativeIds = _hasNativeTypeIds | _hasNativeObjectIds; JsonParser p = other.asParser(); while (p.nextToken() != null) { copyCurrentStructure(p); } return this; } /** * Helper method that will write all contents of this buffer * using given {@link JsonGenerator}. *<p> * Note: this method would be enough to implement * <code>JsonSerializer</code> for <code>TokenBuffer</code> type; * but we can not have upwards * references (from core to mapper package); and as such we also * can not take second argument. */ public void serialize(JsonGenerator gen) throws IOException { Segment segment = _first; int ptr = -1; final boolean checkIds = _mayHaveNativeIds; boolean hasIds = checkIds && (segment.hasIds()); while (true) { if (++ptr >= Segment.TOKENS_PER_SEGMENT) { ptr = 0; segment = segment.next(); if (segment == null) break; hasIds = checkIds && (segment.hasIds()); } JsonToken t = segment.type(ptr); if (t == null) break; if (hasIds) { Object id = segment.findObjectId(ptr); if (id != null) { gen.writeObjectId(id); } id = segment.findTypeId(ptr); if (id != null) { gen.writeTypeId(id); } } // Note: copied from 'copyCurrentEvent'... switch (t) { case START_OBJECT: gen.writeStartObject(); break; case END_OBJECT: gen.writeEndObject(); break; case START_ARRAY: gen.writeStartArray(); break; case END_ARRAY: gen.writeEndArray(); break; case FIELD_NAME: { // 13-Dec-2010, tatu: Maybe we should start using different type tokens to reduce casting? Object ob = segment.get(ptr); if (ob instanceof SerializableString) { gen.writeFieldName((SerializableString) ob); } else { gen.writeFieldName((String) ob); } } break; case VALUE_STRING: { Object ob = segment.get(ptr); if (ob instanceof SerializableString) { gen.writeString((SerializableString) ob); } else { gen.writeString((String) ob); } } break; case VALUE_NUMBER_INT: { Object n = segment.get(ptr); if (n instanceof Integer) { gen.writeNumber((Integer) n); } else if (n instanceof BigInteger)

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> */ protected final void _append(JsonToken type) { Segment next = _hasNativeId ? _last.append(_appendAt, type, _objectId, _typeId) : _last.append(_appendAt, type); if (next == null) { ++_appendAt; } else { _last = next; _appendAt = 1; // since we added first at 0 } } protected final void _append(JsonToken type, Object value) { Segment next = _hasNativeId ? _last.append(_appendAt, type, value, _objectId, _typeId) : _last.append(_appendAt, type, value); if (next == null) { ++_appendAt; } else { _last = next; _appendAt = 1; } } /** * Similar to {@link #_append(JsonToken)} but also updates context with * knowledge that a scalar value was written * * @since 2.6.4 */ protected final void _appendValue(JsonToken type) { _writeContext.writeValue(); Segment next = _hasNativeId ? _last.append(_appendAt, type, _objectId, _typeId) : _last.append(_appendAt, type); if (next == null) { ++_appendAt; } else { _last = next; _appendAt = 1; // since we added first at 0 } } /** * Similar to {@link #_append(JsonToken,Object)} but also updates context with * knowledge that a scalar value was written * * @since 2.6.4 */ protected final void _appendValue(JsonToken type, Object value) { _writeContext.writeValue(); Segment next = _hasNativeId ? _last.append(_appendAt, type, value, _objectId, _typeId) : _last.append(_appendAt, type, value); if (next == null) { ++_appendAt; } else { _last = next; _appendAt = 1; } } protected final void _appendRaw(int rawType, Object value) { Segment next = _hasNativeId ? _last.appendRaw(_appendAt, rawType, value, _objectId, _typeId) : _last.appendRaw(_appendAt, rawType, value); if (next == null) { ++_appendAt; } else { _last = next; _appendAt = 1; } } @Override protected void _reportUnsupportedOperation() { throw new UnsupportedOperationException("Called operation not supported for TokenBuffer"); } /* /********************************************************** /* Supporting classes

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> /********************************************************** */ protected final static class Parser extends ParserMinimalBase { /* /********************************************************** /* Configuration /********************************************************** */ protected ObjectCodec _codec; /** * @since 2.3 */ protected final boolean _hasNativeTypeIds; /** * @since 2.3 */ protected final boolean _hasNativeObjectIds; protected final boolean _hasNativeIds; /* /********************************************************** /* Parsing state /********************************************************** */ /** * Currently active segment */ protected Segment _segment; /** * Pointer to current token within current segment */ protected int _segmentPtr; /** * Information about parser context, context in which * the next token is to be parsed (root, array, object). */ protected JsonReadContext _parsingContext; protected boolean _closed; protected transient ByteArrayBuilder _byteBuilder; protected JsonLocation _location = null; /* /********************************************************** /* Construction, init /********************************************************** */ public Parser(Segment firstSeg, ObjectCodec codec, boolean hasNativeTypeIds, boolean hasNativeObjectIds) { super(0); _segment = firstSeg; _segmentPtr = -1; // not yet read _codec = codec; _parsingContext = JsonReadContext.createRootContext(null); _hasNativeTypeIds = hasNativeTypeIds; _hasNativeObjectIds = hasNativeObjectIds; _hasNativeIds = (hasNativeTypeIds | hasNativeObjectIds); } public void setLocation(JsonLocation l) { _location = l; } @Override public ObjectCodec getCodec() { return _codec; } @Override public void setCodec(ObjectCodec c) { _codec = c; } @Override public Version version() { return com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION; } /* /********************************************************** /* Extended API beyond JsonParser /********************************************************** */ public JsonToken peekNextToken() throws IOException { // closed? nothing more to peek, either if (_closed) return null; Segment seg = _segment; int ptr = _segmentPtr+1; if (ptr >= Segment.TOKENS_PER_SEGMENT) { ptr = 0; seg = (seg == null) ? null : seg.next(); } return (seg == null) ? null : seg.type(ptr); } /* /********************************************************** /* Closeable implementation /********************************************************** */ @Override public void close() throws IOException { if (!_closed) { _closed = true; } } /* /********************************************************** /* Public API, traversal /********************************************************** */ @Override public JsonToken nextToken() throws IOException { // If we are

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> closed, nothing more to do if (_closed || (_segment == null)) return null; // Ok, then: any more tokens? if (++_segmentPtr >= Segment.TOKENS_PER_SEGMENT) { _segmentPtr = 0; _segment = _segment.next(); if (_segment == null) { return null; } } _currToken = _segment.type(_segmentPtr); // Field name? Need to update context if (_currToken == JsonToken.FIELD_NAME) { Object ob = _currentObject(); String name = (ob instanceof String) ? ((String) ob) : ob.toString(); _parsingContext.setCurrentName(name); } else if (_currToken == JsonToken.START_OBJECT) { _parsingContext = _parsingContext.createChildObjectContext(-1, -1); } else if (_currToken == JsonToken.START_ARRAY) { _parsingContext = _parsingContext.createChildArrayContext(-1, -1); } else if (_currToken == JsonToken.END_OBJECT || _currToken == JsonToken.END_ARRAY) { // Closing JSON Object/Array? Close matching context _parsingContext = _parsingContext.getParent(); // but allow unbalanced cases too (more close markers) if (_parsingContext == null) { _parsingContext = JsonReadContext.createRootContext(null); } } return _currToken; } @Override public String nextFieldName() throws IOException { // inlined common case from nextToken() if (_closed || (_segment == null)) return null; int ptr = _segmentPtr+1; if (ptr < Segment.TOKENS_PER_SEGMENT && _segment.type(ptr) == JsonToken.FIELD_NAME) { _segmentPtr = ptr; Object ob = _segment.get(ptr); // inlined _currentObject(); String name = (ob instanceof String) ? ((String) ob) : ob.toString(); _parsingContext.setCurrentName(name); return name; } return (nextToken() == JsonToken.FIELD_NAME) ? getCurrentName() : null; } @Override public boolean isClosed() { return _closed; } /* /********************************************************** /* Public API, token accessors /********************************************************** */ @Override public JsonStreamContext getParsingContext() { return _parsingContext; } @Override public JsonLocation getTokenLocation() { return getCurrentLocation(); } @Override public JsonLocation getCurrentLocation() { return (_location == null) ? JsonLocation.NA : _location; } @Override public String getCurrentName() { // 25-Jun-2015, tatu: as per [databind#838], needs to be same as ParserBase if (_currToken

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS> there are <= 15 values in JsonToken enum TOKEN_TYPES_BY_INDEX = new JsonToken[16]; JsonToken[] t = JsonToken.values(); // and reserve entry 0 for "not available" System.arraycopy(t, 1, TOKEN_TYPES_BY_INDEX, 1, Math.min(15, t.length - 1)); } // // // Linking protected Segment _next; // // // State /** * Bit field used to store types of buffered tokens; 4 bits per token. * Value 0 is reserved for "not in use" */ protected long _tokenTypes; // Actual tokens protected final Object[] _tokens = new Object[TOKENS_PER_SEGMENT]; /** * Lazily constructed Map for storing native type and object ids, if any */ protected TreeMap<Integer,Object> _nativeIds; public Segment() { } // // // Accessors public JsonToken type(int index) { long l = _tokenTypes; if (index > 0) { l >>= (index << 2); } int ix = ((int) l) & 0xF; return TOKEN_TYPES_BY_INDEX[ix]; } public int rawType(int index) { long l = _tokenTypes; if (index > 0) { l >>= (index << 2); } int ix = ((int) l) & 0xF; return ix; } public Object get(int index) { return _tokens[index]; } public Segment next() { return _next; } /** * Accessor for checking whether this segment may have native * type or object ids. */ public boolean hasIds() { return _nativeIds != null; } // // // Mutators public Segment append(int index, JsonToken tokenType) { if (index < TOKENS_PER_SEGMENT) { set(index, tokenType); return null; } _next = new Segment(); _next.set(0, tokenType); return _next; } public Segment append(int index, JsonToken tokenType, Object objectId, Object typeId) { if (index < TOKENS_PER_SEGMENT) { set(index, tokenType, objectId, typeId); return null; } _next = new Segment(); _next.set(0, tokenType, objectId, typeId); return _next; } public Segment append(int index, JsonToken tokenType, Object value) { if (index < TOKENS_PER_SEGMENT) { set(index, tokenType, value); return null; } _next = new Segment(); _next

JacksonDatabind, 44

<FILEB>
<CHANGES>
if (!_class.isAssignableFrom(subclass)) {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<CHANGES>
Class<?> next = subclass.getSuperclass();
if (next == _class) { // straight up parent class? Great.
return new SimpleType(subclass, _bindings, this,
_superInterfaces, _valueHandler, _typeHandler, _asStatic);
}
if ((next!= null) && _class.isAssignableFrom(next)) {
JavaType superb = _narrow(next);
return new SimpleType(subclass, _bindings, superb,
null, _valueHandler, _typeHandler, _asStatic);
}
<CHANGEE>
<CHANGES>
Class<?>[] nextI = subclass.getInterfaces();
for (Class<?> iface : nextI) {
if (iface == _class) { // directly implemented
return new SimpleType(subclass, _bindings, null,
new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic);
}
if (_class.isAssignableFrom(iface)) { // indirect, so recurse
JavaType superb = _narrow(iface);
return new SimpleType(subclass, _bindings, null,
new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
}
}
<CHANGEE>
<CHANGES>
throw new IllegalArgumentException("Internal error: Can not resolve sub-type for Class "+subclass.getName()+" to "
+_class.getName());
<CHANGEE>
<FILEE>
<FILEB> if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } TypeBindings b = TypeBindings.emptyBindings(); return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false); } @Override @Deprecated protected JavaType _narrow(Class<?> subclass) { if (_class == subclass) { return this; } // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. // TODO: fix in 2.8 <CHANGES> <CHANGEE> /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " +_class.getName()); */ return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); <CHANGES> <CHANGEE> // Otherwise, stitch together the hierarchy. First, super-class <CHANGES> <CHANGEE> // if not found, try a super-interface <CHANGES> <CHANGEE> // should not get here but... <CHANGES> <CHANGEE> } @Override public JavaType withContentType(JavaType contentType) { throw new IllegalArgumentException("Simple types have no content types; can not call withContentType()"); } @Override public SimpleType withTypeHandler(Object h) { if (_typeHandler == h) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, _valueHandler, h, _asStatic); } <FILEE> <SCANS>package com.fasterxml.jackson.databind.util; import java.util.Iterator; import java.util.NoSuchElementException; /** * Iterator implementation used to efficiently expose contents of an * Array as read-only iterator. */ public class ArrayIterator<T> implements Iterator<T>, Iterable<T> { private final T[] _a; private int _index; public ArrayIterator(T[] a) { _a = a; _index = 0; } @Override public boolean hasNext() { return _index < _a.length; } @Override public T next() { if (_index >= _a.length) { throw new NoSuchElementException(); } return _a[_index++]; } @Override public void remove() { throw new UnsupportedOperationException(); } @Override public Iterator<T> iterator() { return this; } }